Enumerable.Range in and Expression and Entity Framework
- by eka808
I'm currently developping an expression method (used in linq to entity queries) who has to give me
a daycount for a given period (start date and end date)
decrementing this daycount if specials days are in the period.
My idea was the following :
Generate an enumerable with all the dates (and with Enumerable.Range)
Make a .Where on this enumerable to remove the specials dates Like a MyEnumerable.Where(a = a != "20120101")
After that, return a MyEnumerable.Count()
I come with this code :
return (p) => Enumerable
.Range(1, 4)
.Where(a => a != 20120101)
.AsQueryable()
.Count()
I tried to cast as a list, as a queryable, both (like the example) and no way ! it doesn't work ! I always get this error :
LINQ to Entities does not recognize the method 'System.Collections.Generic.IEnumerable`1[System.Int32] Range(Int32, Int32)' method, and this method cannot be translated into a store expression.
Have you got an idea about that ?
Using an enumerable is of course not mandatory, any working solutions is good ^^
Thank's by advance !