什么是此SQL查询的Linq查询 [英] what is the Linq query of this sql query
本文介绍了什么是此SQL查询的Linq查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选择0 NBRANCH_SL,0 NCM_SL,''''CNAME Union ALL从CM_MT_REF_CODE
Select 0 NBRANCH_SL, 0 NCM_SL,'''' CNAME Union ALL Select NBRANCH_SL,NCM_SL,CNAME from CM_MT_REF_CODE
推荐答案
选择NBRANCH_SL,NCM_SL,CNAME LINQ语句,因为实际上您将需要创建3个语句.
此处给出了一个示例.
我个人认为这个例子有点钝.
我的示例是创建要使用的对象的特定类型.
Its not as simple as just creating single LINQ statement, because you will actually need to create 3 statements.
An example is given here.
Personally I think the example is a little obtuse.
My example would be to create a specific type of the object you want to use.
public class CM_MT_REF_CODE
{
public Int32 NBRANCH_SL { get; set; }
public Int32 NCM_SL { get; set; }
public string CNAME { get; set; }
}
然后创建您的初始元素,将其添加到列表中,进行查询,然后将范围添加到列表中.
Then create your initial element, add it to a list, do your query, then add the range to your list.
List<CM_MT_REF_CODE> results = new List<CM_MT_REF_CODE>();
var query = from CM_MT_REF_CODE c in table
select c;
results.Add(new CM_MT_REF_CODE { CNAME = "<Select>" });
results.AddRange(query);
//use results
这篇关于什么是此SQL查询的Linq查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文