在Silverlight中使用LINQ获取表的单列 [英] Getting single column of a table using LINQ in Silverlight

查看:119
本文介绍了在Silverlight中使用LINQ获取表的单列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Salam.o.alaikum,

我正在开发Silverlight应用程序,已经通过WCF数据服务连接到数据库.

Salam.o.alaikum,

I am developing an Silverlight application, i have connected to my database through a WCF Data Service.. I can succeffuly get a table using

var query1 = (from s in catx.Traders where s.BranchCode == selectedBranchCode select s)  ;
var dquery1 = (query1) as DataServiceQuery<CatsMainService.Trader> ;
dquery1.BeginExecute(AccountsLoaded, dquery1);




我想获得此表的单个列...所以我尝试了




i want to get a single column of this table... so i tried

var query1 = (from s in catx.Traders where s.BranchCode == selectedBranchCode select s.Accounts)  ;
var dquery1 = (query1) as DataServiceQuery<CatsMainService.Trader> ;
dquery1.BeginExecute(AccountsLoaded, dquery1);




帐户"是我的列名...
我在BeginExecute()处收到nullReferenceException,因为query1尚未翻译..它说
"{将Linq表达式转换为URI时出错:只能在上一次导航后指定查询选项(orderby,where,take,skip).}"

我用谷歌搜索...并尝试了很多其他查询...但是有相同的例外...请纠正我...我误会了...

谢谢




''Accounts'' is my column name...
I am getting nullReferenceException at BeginExecute() because query1 is not being translated.. it says
"{Error translating Linq expression to URI: Can only specify query options (orderby, where, take, skip) after last navigation.}"

I googled... and tried this thing with many other queries... but had the same exception... kindly correct me... where i m mistaking...

Thanks

推荐答案

我猜想DataServiceQuery<CatsMainService.Trader>中的CatsMainService.Trader应该更改为Accounts列的类型.
I would guess that CatsMainService.Trader in DataServiceQuery<CatsMainService.Trader> should be changed to the type of the Accounts column.


这篇关于在Silverlight中使用LINQ获取表的单列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆