此代码会导致NotSupportedException。为什么我们需要使用AsEnumerable()方法?
var detailList = context.Details.Where(x => x.GetType().GetProperty("Code").GetValue(x,null).ToString() == "00101").ToList();
但是这段代码有效。
var detailList = context.Details.AsEnumerable().Where(x => x.GetType().GetProperty("Code").GetValue(x,null).ToString() == "00101").ToList();
MSDN说:
- AsEnumerable() Returns the input typed as IEnumerable
那么,为什么我们需要使用AsEnumerable()方法?
为什么在使用'var detailList = context.Details.Where(x => x.Code.ToString()==“00101”)时使用了反射。 – 2015-03-02 14:51:57