Created
October 11, 2016 17:24
-
-
Save dhont/4d38d13e9a13bdad066fce9706fad888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EfBuilderExtensions | |
{ | |
/// <summary> | |
/// super simple and dump translation of .Contains because is not supported pe EF plus | |
/// this translates to contains in EF SQL | |
/// </summary> | |
/// <param name="source"></param> | |
/// <param name="contains"></param> | |
/// <returns></returns> | |
public static IQueryable<Raspuns> WhereRaspunsContains(this IQueryable<Raspuns> source, IList<int> contains) | |
{ | |
var ors = contains | |
.Aggregate<int, Expression<Func<Raspuns, bool>>>(null, (expression, id) => | |
expression == null | |
? (a => a.IdIntrebare == id) | |
: expression.Or(a => a.IdIntrebare == id)); | |
return source.Where(ors); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment