I'm just starting to use LinqKit with EntityFramework 6.0.2 and I have the following question...
Why does this:
public static readonly Expression<Func<MyEnum, string>> ConvertToString = e =>
e == MyEnum.One
? "one"
: e == MyEnum.Two
? "two"
: "zero";
private static string GetSomethingElse(IQueryable<EnumTest> things)
{
var ret = things
.AsExpandable()
.Select(c => Program.ConvertToString.Invoke(c.SomeEnum))
.First();
return ret;
}
throw:
An unhandled exception of type 'System.InvalidCastException'
occurred in LinqKit.dll
Additional information: Unable to cast object of type
'System.Linq.Expressions.FieldExpression' to type
'System.Linq.Expressions.LambdaExpression'.
but this:
private static string GetSomething(IQueryable<EnumTest> things)
{
Expression<Func<MyEnum, string>> ConvertToString = e => e == MyEnum.One
? "one"
: e == MyEnum.Two
? "two"
: "zero";
var ret = things
.AsExpandable()
.Select(c => ConvertToString.Invoke(c.SomeEnum))
.First();
return ret;
}
works fine?