我们可以将LINQKIT与WCF数据服务一起使用

时间:2014-06-05 11:52:59

标签: wcf-data-services linqkit

我在网上找不到任何使用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);

1 个答案:

答案 0 :(得分: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;