本文介绍了从Sql查询到Linq到Sql的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我转换后的结果:

我的Sql查询:

从大学选择UnivId;

但是我确实喜欢这样:

var v =从db中的i开始,大学选择i;
然后我得到了所有专栏.
但是我只需要UnivId.
而且我还需要如何将UnivId添加到列表中以及如何将此列表结果绑定到
SilverLight中的ComboBox.

谢谢
vijay

Please Tell me Converted result:

My Sql Query :

select UnivId from University;

But I did Like this:

var v = from i in db.University select i;
Then I got All Columns.
But I Need Only UnivId''s.
And Also I need How to Add That UnivId''s to List and How to Bind this List result to
ComboBox In SilverLight.

Thanks
vijay

推荐答案


var v = from i in db.University select i.UnivId;
List<int> list = v.ToList();




但组合中没有描述

所以可能您应该改成新"商品





but you wouldn''t have a description in your combo

so may be you should make a "new" item instead


var v = from i in db.University select new{ Id = i.UnivId, Description = i.Univ};
IList list = v.ToList();


这篇关于从Sql查询到Linq到Sql的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 22:21