C#中sql语句如何转为Linq语句。

如何将下列Sql语句转为Linq语句

select 
t2.PROJECT_CODE as 项目号,t2.BOM_CODE as BOM编号,t1.PID as bom主表id, t1.id as BOM子表ID,t2.MAT_NAME as 项目产品,
t1.COMPONENT_CODE as 物料编码, t1.COMPONENT_QTY*t1.SET_NUMBER as 需求数量,
t3.ID as 备料表ID,t3.MAT_CODE as 备料表物料编码,t3.MAT_QTY as 备料数量,t3.STACKCODE  as 物料所在货位,

CASE WHEN t3.MAT_QTY=0 or t3.MAT_QTY is NULL THEN '未备'
WHEN t1.COMPONENT_QTY*t1.SET_NUMBER-t3.MAT_QTY<=0 THEN '备好了'
ELSE '备了部分' END as 状况
from  TAB_BOMS AS t1

left JOIN TAB_BOM AS t2 on t1.pid=t2.id

LEFT JOIN TAB_PRES AS t3 on t3.bomsid=t1.id  

where t2.PROJECT_CODE='TS56' 

order by 状况 asc
caozhy
贵阳老马马善福专门编写代码的老马就是我! 之前回答一个类似的问题,写了半天到现在也没有采纳。你们就作吧
9 个月之前 回复

1个回答

https://www.linqpad.net/Download.aspx 转换工具,你值得拥有、

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
把sql语句转为Linq?
SELECT * FROM Emp_EmpProduce A WHERE EmpPro_Time = (SELECT TOP 1 EmpPro_Time FROM "); strWhere.Append(" Emp_EmpProduce WHERE Cus_ID = A.Cus_ID and Emp_IdentityCard=a.Emp_IdentityCard and Type_id=a.Type_id ORDER BY EmpPro_Time DESC) and Cus_ID=0 and Emp_IdentityCard='1' and IsLess=0,rnrn请教各位高手如何把这句Sql语句转换为Linq语句。rnrnrnfrom e in query where e.IsLess==0 && e.Type_Id==typeId && e.Emp_BllType==0 && e.EmpPro_Time ==(from c in query where c.Cus_ID == e.Cus_ID && c.Emp_IdentityCard == e.Emp_IdentityCard && c.Type_Id == e.Type_Id orderby c.EmpPro_Time descending select c.EmpPro_Time).First() select e ,报在 LINQ 表达式中检测到循环。
把sql语句转为Linq
select * from Core_Module where IsDelete=0 and ModuleType<>3 rnand ParentID in(rnselect ID from Core_Module where ParentID = @parentid union select @parentid as ID ) rnorder by sequencernrn帮忙把这个sql语句转成Linq的形式。其中 @parentid 是传进来的参数
怎样以下SQL语句转为LINQ查询?
自己转换了一个,但是得不到期望的结果...rnSQL语句:rn[code=SQL]select top 5 authorName,count(*)rnfrom dbo.authorsrngroup by authorNamernhaving authorName like '赵%'rnorder by count(*) desc [/code]rnrn自己转换的LINQ查询: rn[code=C#]rn V1DataContext DB = new V1DataContext();rn var queryName = (from A in DB.authorsrn group A by newrn rn authorName = A.authorNamern into grArn select newrn rn authorName = grA.Key.authorName,rn Quantity = grA.Count()rn into orderbygrArn where orderbygrA.authorName.StartsWith("张")rn orderby orderbygrA.Quantity descendingrn select orderbygrA.authorName).Distinct().Take(7);rn[/code]
【LINQ语句】LINQ语句
LINQ(Language Integrated Query)是C#和VB.NET中的统一查询语法,用于保存和检索不同来源的数据。它集成在C#或VB中,从而消除了编程语言和数据库之间的不匹配,以及为不同类型的数据源提供单个查询接口。例如,SQL是一种结构化查询语言,用于保存和检索数据库中的数据。同样的,LINQ是一个用C#和VB.NET构建的结构化查询语法,用于保存和检索
sql,linq to sql 语句
如图:rn[img=http://hi.csdn.net/attachment/201104/19/7691684_1303210479EDc2.jpg][/img]rnrn我要将 时间为:2011-4-16 16:13:16 的这两条记录合并成一条记录 时间为:2011-4-18 16:13:16 的这两条记录合并成一条记录rn请问sql 和ling to sql该怎样写呢
linq语句转SQL语句
var ret = from x in lsrn where (rn string.IsNullOrEmpty(arg.QueryText) ? true : rn (rn (x.a?? "").ToUpper().Contains(arg.QueryText.ToUpper())rn || (x.b?? "").ToUpper().Contains(arg.QueryText.ToUpper())rn || (x.c?? "").ToUpper().Contains(arg.QueryText.ToUpper())rn )rn看到这个语句大致能明白其含义,但在转SQL时无从下手,期望答案
sql语句装linq语句
如题,请问下面这段代码要怎么写成linq语句呢rn[code=SQL]select 可用侦查工具rnfrom network_attackrnwhere 攻击形式='破坏数据' and 攻击工具='灰鸽子'rngroup by 可用侦查工具rnorder by count(可用侦查工具)descrn[/code]rn
SQL语句转为Access语句
select a.*, b.pay,c.used,b.pay-c.used as have from studentInfo a left join rn(select stuID,sum(money) as pay from payInfo group by stuID) b on a.sid=b.stuID left join rn(select stuID,sum(price*num) used from attend group by stuID) c on a.sid = c.stuIDrnSqlServer中可以执行,Access中提示操作符丢失,请问,应该怎么改一下?
C#语句如何转为VB.Net?
this.pager.PageChanged += new Wuqi.Webdiyer.PageChangedEventHandler(this.ChangePage);rnthis.Load += new System.EventHandler(this.Page_Load);rnrn请帮忙写写。tks.
C#的linq语句
 /查询表达式必须以form子句开头,以select或者group子句结束,在这两个子句之间,可以使用         ///where 、orderby、join、let和其他的from子句 本章要点 用列表在对象上执行传统查询 扩展方法 LINQ查询操作符 平行LNQ 表达式树 本章源代码下载地址( wrox. com ) ...
一个sql语句的linq
这句话linq怎么写?rnrnselect t.* from plan t where mainpage = (select top 1 mainpage from plan where pageid= t.pageid order by NEWID())
sql语句转成linq
select SUM(P.W) as w from order o left join product p on o.pid=p.ID where o.oid=100这个sql语句怎么转成Linq啊?求教
sql语句转linq
select name from category where id not in (select parentid from category where parentid is not null)rnrn这是我的SQL语句,现在我要转化成linq写法,都写不成功,求高手帮帮忙啊,帮我一下啦。rn
Linq to Sql语句详解
Linq to Sql语句详解,讲述了Linq to Sql语法详解,包括Linq to sql的动态语句,和继承的应用。还有在分层结构情况下的应用。
LINQ to SQL语句入门篇
介绍 LINQ to SQL 的基本语法 目录: LINQ to SQL语句(1)之Where LINQ to SQL语句(2)之Select/Distinct LINQ to SQL语句(3)之Count/Sum/Min/Max/Avg ... LINQ to SQL语句(25)之继承
Sql语句转LinQ
select * from (select row_number() over(partition by TeamID order by IssueDate) as rownum,* from TeamIssue) t rnwhere t.rownum=1rn把这句sql代码,转换成Linq代码,哪位大虾帮帮忙!灰常感谢!
mysql 的sql语句与Linq
SELECT dept.DepartmentId,dept.DptName FROM tbldepartment as deptnJOIN tblconsult as consult on dept.DepartmentId in (consult.DepartmentId ,consult.ApplyDepartmentId)nwhere consult.Id = 726 nn这个语句用linq 怎么写 ,主要是 dept.DepartmentId in (consult.DepartmentId ,consult.ApplyDepartmentId) 这一句
LINQ to SQL语句
LINQ to SQL语句.。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 使用Linq的工具
Linq To Sql 语句求助
sql语句:select A.id,A.name from Arn where A.id not in (select B.id from B)rn实现这种情况,linq语句怎么写?
SQL语句转换成LINQ
select * from [BXTechnology].[dbo].[tb_News] where typeID IN(select ID from [BXTechnology].[dbo].[tb_Navigation] where parentID=5)rn想把上面的SQL语句转换成LINQ语句,请问如何实现的?
LINQ to SQL语句(19)之ADO.NET与LINQ to SQL
LINQ to SQL语句(19)之ADO.NET与LINQ to SQL
LINQ TO SQL 对应的SQL语句
有没有什么办法在VS2010中,查看我写的 LINQ to SQL所对应的SQL脚本~~
linq to sql 直接使用SQL语句
select * from tablernrn如果我想直接作为参数在linq中使用 能行不,是LINQ的哪个方法呢 ?rnrn不想用拉姆达表达式。.
C# lamda表达式写LINQ to SQL语句
大家可不可以给一些实例给我参考一下?实在是写不对rndb我不明白是什么意思,看网上好多实例都有db,db自己出不来,我因该如何做呢?现在要做一个注册页面,请大家帮帮忙
C#中SQL语句
请教下哪位大侠能够将以下sql执行语句转化为C#的实现语句:rn[code=SQL]rnuse moniDatarndeclare @no varchar(50),@s varchar(1000)rnset @no='HS303-2'rnset @s='CREATE TABLE [dbo].['+@no+'](rn [起点测点(mpa)] [float] NULL,rn [起点测点(℃)] [float] NULL,rn [起点测点(m3/h)] [float] NULL,rn [终点测点(mpa)] [float] NULL,rn [终点测点(℃)] [float] NULLrn) ON [PRIMARY]'rnif not exists (select * from sysobjects where id=object_id(N'[dbo].['+@no+']') and OBJECTPROPERTY(id,N'IsUserTable')=1)rnbeginrnexec(@s)rnendrn[/code]rn在C#程序中@no的变量为string noName;即@no=noName
C# 中sql语句
select * from ad where 用户名 like "+this.ad.ToString()+" ;rn其中ad为string类型变量rn运行时提示列名ad无效rn怎么改?
C#中的sql语句
string sqlInsert = "INSERT INTO Resource(CityID,UserName,Money,Grain,Population,ModifiedDate) VALUES (@CityID,@UserName,@Money,@Grain,@Population,@ModifiedDate)";rnrn这条语句是什么意思啊?@在这里有什么用,能具体介绍一下它的用法吗?
sqlserver中的in语句在C# linq中的写法
我们知道,在sqlserver中一个in语句通常是这样写的: SELECT * FROM dbo.表名 WHERE SortGID IN ('f30ce6eb-92ab-4ee8-af58-82c7a63c15b7','c98bd939-258b-43d1-8e5b-2e45fd291ef5','f30ce6eb-92ab-4ee8-af58-82c7a63c15b7') 那它在C#中如果
这条C语句怎样转为C#语句?
单位购买了一台DR-Pos58热敏打印机,开发手册中有C语言的打印命令范例,比如:rnSendDataToPrinter(unsigned char *buffer, unsigned int len)rnrn其中:前者为打印数据的指针rn 后者为数据长度,字节rnrn说明书中给出一个简单用例:rnunsigned char *str[2];rnstr[0] = 0x1B;rnstr[1] = 0x40;rnSendDataToPrinter(str, 2);rnrn我用的是C#,想知道若用C#语言的话该如何改写呢?谢谢!rnrn
把下面的sql语句转换成linq语句
select classifytb.name1, count(logtb.cid)rnfrom classifytb,logtbrnwhere classifytb.id=logtb.cidrngroup by classifytb.name1rnrnclassifytb表有下面的字段:rnid 分类的idrnname1 分类的名字rnlogtb表有下面的字段:rnid 日志idrncid 所在分类的id
一条sql语句转换为linq语句
rnselect operator, count(*) from t_ill_fourDiagnosticrnwhere (operateTime between'2010-5-20' AND '2010-5-21')rngroup by operatorrnrn用linq怎么写?
sql 语句,改为linq语句,谢谢!
这个是linq 语句,怎么样才能把他的语句改为linq语句.rnselect Top 4 * from(select Row_Number() over (order by id) AS RowNumber, * from Task) A where RowNumber>4 * (1-1)rn
sql语句改写成LINQ语句
C#代码如何将下面的sql语句改写成LINQ语句rnSELECT rn shopIdrn ,shopNamern ,shopNorn COUNT(*) AS countrn SUM(total) AS totalrnFROM rn trn_shoprnGROUP BY rn shopIdrn ,shopNamern ,shopNornORDER BY rn totalrn数据源rnList dataList = new List();rn[img=https://img-bbs.csdn.net/upload/201601/25/1453690262_134816.png][/img]rn
关于SQL语句转换成linq语句
SELECT * FROM dbo.[USER] u,n(SELECT ua.User_Attention_Object_Id FROM dbo.User_Attention ua,dbo.[USER] u nWHERE u.User_Id=ua.User_Attention_User_Id AND ua.User_Attention_User_Id=3) uaidnWHERE u.User_Id=uaid.User_Attention_Object_Idnnn还望好心人帮我一下,感激不尽!!
如何将下面的SQL语句改成LINQ语句
select * from dbo.View_1 where DepName like '%" + textbox + "%'or UserName like '%" + textbox + "%'"
将如下sql语句翻译成linq语句~~~~
[code=SQL]SELECT Areate,ColorName,C FROM V AS ArnWHERE C=(SELECT MAX(C) FROM V WHERE Areate=A.Areate )rn[/code]rn翻译成Linq语句,谢谢~~~
sql语句转linq语句,帮帮忙!
帮帮忙,把下面的sql语句转为linq语句,谢谢了!rnrnSELECT top 100 *rnFROM tabl1rnWHERE ID = '1332' AND CREDATE > '2010-03-11' and reserved is null
将sql语句转换成为linq语句
一个比较有点特殊的转换,供大家参考一下,希望能够帮助想我一样对linq语句不太熟悉的伙伴!
【求助】SQL语句转化EF Linq语句
rn把这条SQL语句转换为EF语句rnrn[code=sql]SELECT rnActivityId,OpenId, HeadImg, NickName, WXHeadImg,rn (select COUNT(*) from SupportLog rn where rn OpenId=mb_Activity.OpenId and CreateTime>'2015-04-13' and CreateTime<'2015-04-22')as [Count]rnFROM dbo.mb_Activity[/code]rnrn[img=https://img-bbs.csdn.net/upload/201505/28/1432797709_555680.png][/img]
EF框架的linq语句转变sql语句
我想把linq的查询转变为直接的sql查询rn[code=csharp]public class myModelrnrn public string Name get; set; rn public double Data get; set; rnrn public static List FindTimePie(DateTime beginTime, DateTime endTime)rn rn using (LogEntities db = new LogEntities ())rn rn var nameList = (from v in db.Versionrn join f in db.FilePath on v.Id equals f.VersionIdrn select newrn rn v.Name,rn v.Datarn ).Where(x => x.Data.CompareTo(beginTime) > 0 && x.Data.CompareTo(endTime) < 0).GroupBy(x => x.Name).ToList();rn List data = new List(nameList.GroupBy(x => x.Key).Count());rn for (int i = 0; i < nameList.GroupBy(x => x.Key).Count(); i++)rn rn data.Add(new myModelrn rn Name = nameList[i].Key,rn Data = nameList[i].Count()rn );rn rn return data;rn rn rn[/code]rnrn数据库语句是这个rn[code=sql]SELECT b.Name ,rn COUNT(1) AS NumrnFROM ( SELECT *rn FROM ( SELECT [t0].[Name] ,rn [t0].[Data]rn FROM [Version] AS [t0]rn INNER JOIN [FilePath] AS [t1] ON [t0].[Id] = [t1].[VId]rn ) AS arn WHERE a.Data BETWEEN '2015-06-29' AND '2016-01-28'rn ) AS brnGROUP BY b.Name;[/code]rn这个是结果[img=https://img-bbs.csdn.net/upload/201610/21/1477038376_355179.png][/img]
相关热词 c# login 居中 c# 考试软件 c# 自然语言分析 c# 分段读取文件 c# 泛型反射 c#打断点 c# 时间转多少秒 c# 线程函数加参数 c# modbus 读取 c#查询集合表