KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have defined a GenericRepository class which does the db interaction. protected GenericRepository rep = new GenericRepository(); And in my BLL classes, I can query the db like: public List<Album> GetVisibleAlbums(int accessLevel) { return rep.Find<Album>(a => a.AccessLevel.BinaryAnd(accessLevel)).ToList(); } BinaryAnd is an extension method which checks two int values bit by bit. e.g. AccessLevel=5 => AccessLevel.BinaryAnd(5) and AccessLevel.binaryAnd(1) both return true. However I cannot use this extension method in my LINQ queries. I get a runtime error as follows: LINQ to Entities does not recognize the method 'Boolean BinaryAnd(System.Object, System.Object)' method, and this method cannot be translated into a store expression. Also tried changing it to a custom method but no luck. What are the workarounds? Should I get all the albums and then iterate them through a foreach loop and pick those which match the AccessLevels?
Tags (comma-separated)
Save Edits
Cancel