How can I pass in a params of Expression<Func<T, object>> to a method?
Posted
by
Pure.Krome
on Stack Overflow
See other posts from Stack Overflow
or by Pure.Krome
Published on 2011-01-17T05:46:33Z
Indexed on
2011/01/17
5:53 UTC
Read the original article
Hit count: 247
Hi folks,
I have the following two methods :-
public static IQueryable<T> IncludeAssociations<T>(this IQueryable<T> source,
params string[] associations)
{ ... }
public static IQueryable<T> IncludeAssociations<T>(this IQueryable<T> source,
params Expression<Func<T, object>>[] expressions)
{ ... }
Now, when I try and pass in a params of Expression<Func<T, object>>[]
, it always calls the first method (the string[]' and of course, that value is
NULL`)
Eg.
Expression<Func<Order, object>> x1 = x => x.User;
Expression<Func<Order, object>> x2 = x => x.User.Passport;
var foo = _orderRepo
.Find()
.IncludeAssociations(new {x1, x2} )
.ToList();
Can anyone see what I've done wrong? Why is it thinking my params are a string? Can I force the type, of the 2x variables?
© Stack Overflow or respective owner