【问题标题】:Can we use LINQKIT with WCF data services我们可以将 LINQKIT 与 WCF 数据服务一起使用吗
【发布时间】:2017-10-20 23:53:00
【问题描述】:

我在网上找不到任何资源,其中包含将 LINQKIT 与 WCF 数据服务结合使用的示例。可能吗 ?我尝试这样做,但它在方法访问中的 ExpressionVisitor 类中失败,错误 - 未处理的表达式类型 10000。

throw new Exception (string.Format ("Unhandled expression type: '{0}'", exp.NodeType));

有没有其他选择。

表达式示例如下所示。它构建成功,但在运行时出现上述错误。

            DataServiceQuery<ClassName> query = (DataServiceQuery<ClassName>)
            (from c in data.<ClassName>.AsExpandable()
            where c.<ChildClass>.Any(SamplePredicate.Compile())
            select c);

【问题讨论】:

    标签: wcf-data-services linqkit


    【解决方案1】:

    是的,有可能:

    try
            {
                PoseidonReadEntities poseidonReadEntities = new PoseidonReadEntities(GetServiceUri());
    
                var predicate = PredicateBuilder.New<vw_PDS_Grants>(true);
    
    
                predicate = predicate.And(g => g.Trust == trShortCode);
    
                if (searchTGN.HasValue)
                {
                    predicate = predicate.And(g => g.TrustGrantNo == (int)searchTGN);
    
                }
    
                DataServiceQuery<vw_PDS_Grants> dsGrantQuery = poseidonReadEntities.vw_PDS_Grants;
    
                DataServiceQuery<vw_PDS_Grants> gq = (DataServiceQuery<vw_PDS_Grants>)dsGrantQuery.Where(predicate).OrderByDescending(g => g.GrantID).Take((int)rowsToReturn);
    
                var grants = await Task.Factory.FromAsync(gq.BeginExecute(null, null), asyncResult => gq.EndExecute(asyncResult));
    
                DS_vw_PDS_Grants = grants.ToList();
    
                return DS_vw_PDS_Grants;
            }
            catch (DataServiceQueryException Ex)
            {
                string error = Ex.Message;
            }
    
            return null;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-08
      • 1970-01-01
      • 2014-10-21
      • 2011-03-06
      • 2012-04-25
      • 2022-01-04
      相关资源
      最近更新 更多