2012-07-06 66 views
0

我写了这个令人敬畏的代码,我现在遇到了麻烦。全部选择EF和lambda

目前工作例如:

complete item = ReliableExecution.RetryWithExpression<complete, complete>(u => u.FirstOrDefault(x => x.str_en == segment)); 

,这是RetryWithExpression代码的一部分:

public static TValue RetryWithExpression<T, TValue>(Func<ObjectSet<T>, TValue> func, Int32 retryInfiniteLoopGuard = 0) 
    where T : class 
{ 
    RetryPolicy policy = RetryPolicyProvider.GetSqlAzureRetryPolicy(); 
    using (DDEntities dataModel = new DDEntities()) 
    { 
     var entitySet = dataModel.CreateObjectSet<T>(); 

       ... 

       var query = policy.ExecuteAction(() => (func(entitySet))); 

       ... 

现在我的问题是如何改变上述选择查询做SELECT * ?

我曾尝试这一点,但它告诉我有关错误的事情,我不明白:

complete item = ReliableExecution.RetryWithExpression<complete, complete>(u => u.Select(x => x.str_en != "")); 
+0

你能发布错误信息吗? – nemesv 2012-07-06 16:57:03

+0

@nemesv 无法将类型'System.Linq.IQueryable '隐式转换为'DDModel.complete'。存在明确的转换(你是否缺少演员?) – 2012-07-06 17:05:25

+1

我认为你的意思是'Where'而不是'Select',所以它应该是'u => u.Where(x => x.str_en!=“”) '但基于错误消息,它也不会工作......没有完整的'RetryWithExpression'代码,很难说出为什么它不工作。 – nemesv 2012-07-06 17:14:06

回答

0

IQueryable<complete> items = ReliableExecution.RetryWithExpression<complete, IQueryable<complete>>(u => u.Where(x => x.str_en != ""));