I'm trying to find a way to implement a Linq-to-Entities compiled query of the form:
Func<MyEntities, List<int>, IQueryable<MyClass>> query = System.Data.Objects.CompiledQuery.Compile(
(MyEntities entities, List<int> IDs) => (
(from au in entities.Mine where IDs.Any(x => x == au.ID) select au)
));
Because only scalar parameters can be passed to CompiledQuery.Compile the above fails. I'm trying to find some clever way to pass a comma delimited list of integers as a string and use that in the L2E query along the lines of:
Func<MyEntities, string, IQueryable<MyClass>> query = System.Data.Objects.CompiledQuery.Compile(
(MyEntities entities, string IDs) => (
(from au in entities.Mine where IDs.Split(',').Any(x => Convert.ToInt32(x) == au.ID) select au)
));
But that doesn't work due to the unsupported Split function.
Any clever ideas about how this could be implemented?