I am quite sure that this question has already been asked several times, and I deceive him to ask him again, but I did some research, and, unfortunately, I did not find my pleasure on the Internet ...
I have an IQueryable:
triggers = triggers.Where(t => GetIdFromName(t.Name) == filter.Id.ToString());
The GetIdFromName function gets the part of the name to get the identifier:
public string GetIdProfiloFromName(string name)
{
return name.Substring(name.IndexOf(NameFirstSeparator)+1,name.IndexOf(NameSecondSeparator)-name.IndexOf(NameFirstSeparator)-1);
}
I know this is not good, but it is the best that I could do so far. My question is that using Linq for sql is not allowed using these two statements. The application causes an error, while this is normal:
triggers = triggers.Where(t => t.Name.Substring(t.Name.IndexOf(NameFirstSeparator) + 1, t.Name.IndexOf(NameSecondSeparator) - t.Name.IndexOf(NameFirstSeparator) - 1) == filter.Id.ToString());
I suspect that the GetIdFromName function should give something different from the string, but I'm really curious about what and how ...
Thanks for your enlightenment,
Yoann
[EDIT] Update to what I have understood so far:
, , - :
static Expression<Func<Trigger,string, bool>> IsId = (a,b) => a.name.Substring(a.name.IndexOf(NameFirstSeparator) + 1, a.name.IndexOf(NameSecondSeparator) - a.name.IndexOf(NameFirstSeparator) - 1)==b;
triggers = triggers.Where(func<Trigger,bool>);
, , .
, !!