I have this piece of code:
int chunkSize = 1000;
var chunkQueryBase = _sdb.Entities.Where(m => FirstNumberGiver(m) < SecondNumberGiver(m)).OrderBy(c => c.Id);
var chunkQuery = chunkQueryBase.Take(chunkSize);
var x = chunkQuery.ToString();
var chunks = chunkQuery.ToList();
For example FirstNumberGiver methods is like this:
public int FirstNumberGiver(Entity entity)
{
string numberString = entity.Number;
string numpart1= "";
numpart1= Regex.Match(numberString , @"\d+").Value;
if (numpart1!= "")
{
return (Int32.Parse(numpart1));
}
else return 0;
}
The SecondNumberGiver function is very similar to FirstNumberGiver. The code gives exception at this line :
var chunks = chunkQuery.ToList();
The exception is this:
LINQ to Entities does not recognize the method 'Int32 FirstNumberGiver(Entity)' method, and this method cannot be translated into a store expression.
Is there a solution for this problem? How can I get rid of this error?