我用EF4.1,查询实体时候是这样
this.context.Set<STEP>():
这是个System.Data.Entity.DbSet对象,
有没有办法转换成ObjectQuery<STEP>?
因为我用的一个扩展方法是针对ObjectQuery的:
public static ObjectQuery<T>
Include<T>(this
ObjectQuery<T> query,
Expression<Func<T,
object>> exp)
{
Expression body = exp.Body;
MemberExpression memberExpression =
(MemberExpression)exp.Body;
string path = GetIncludePath(memberExpression);
return query.Include(path);
}
private static string
GetIncludePath(MemberExpression memberExpression)
{
string path = "";
if (memberExpression.Expression
is MemberExpression)
{
path = GetIncludePath((MemberExpression)memberExpression.Expression)
+ ".";
}
PropertyInfo propertyInfo =
(PropertyInfo)memberExpression.Member;
return path + propertyInfo.Name;
}
they say nothing last forever