1

我在网上找不到任何资源,其中包含将 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);
4

1 回答 1

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;
于 2017-10-20T15:53:00.677 回答