Ich versuche, enthält Ausdruck enthält.Keine Methode 'Enthält' existiert auf Typ 'System.Data.Linq.DataQuery`1 [System.Object]'
private Expression<Func<T, bool>> Contains<T>(string property, IEnumerable<dynamic> values, T item)
{
ParameterExpression pe = Expression.Parameter(item.GetType(), "c");
Expression columnNameProperty = Expression.Property(pe, property);
var someValueContain = Expression.Constant(values, values.GetType());
var convertExpression = Expression.Convert(columnNameProperty, typeof(Guid));
Expression expression = Expression.Call(someValueContain, "Contains", new Type[] { }, convertExpression);
return Expression.Lambda<Func<T, bool>>(expression, pe);
}
zur Laufzeit habe ich diese Ausnahme.
"Keine Methode 'Enthält' auf Typ existiert 'System.Data.Linq.DataQuery`1 [System.Object]'."
war die soultion Werte werfen Parameter
private Expression<Func<T, bool>> Contains<T>(string property, IEnumerable<dynamic> values, T item)
{
ParameterExpression pe = Expression.Parameter(item.GetType(), "c");
Expression columnNameProperty = Expression.Property(pe, property);
Guidvalues = values.Cast<Guid>().ToList();
var someValueContain = Expression.Constant(Guidvalues, Guidvalues.GetType());
var convertExpression = Expression.Convert(columnNameProperty, typeof(Guid));
Expression expression = Expression.Call(someValueContain, "Contains", new Type[] { }, convertExpression);
return Expression.Lambda<Func<T, bool>>(expression, pe);
}
das Problem, dass die Werteliste mehr als 10000 ist so die Leistung war gering, und ich habe diese Ausnahme
„Die zur Liste eingehende Anfrage hat zu viele Parameter. Der Server unterstützt maximal 2100 Parameter. Reduzieren Sie die Anzahl der Parameter und senden Sie die Anfrage erneut an . "
ich es eine Möglichkeit, dynamisch Lambda-Ausdruck zu erstellen, die wie diese Abfrage zu generieren
select * from x where id in (select id from y)
Enthält ist eigentlich eine Erweiterung Methode auf 'System.Linq.Queryable'. – Aron
Warum ist 'values'' DataQuery