需要SQL查询到Linq [英] Need Sql query to Linq
本文介绍了需要SQL查询到Linq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的Sql查询(更新表名设置名称="XXXX",其中Id = 1)如何在Linq Plz中编写此代码,这对Linq是我的新手.
解决方案
你好,
请参阅下面的链接.可能会对您有帮助.
http://atikpassion.blogspot.in/2011/10/c- linq-insertupdate-delete-does-exist.html [ ^ ]
http://rochcass.wordpress.com/2011 /03/11/linq-to-sql-simple-insert-update-and-delete/ [ http://msdn.microsoft.com/zh-我们/library/bb386931.aspx [ ^ ]
http://weblogs. asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx [ 使用( var myContext = 新 DataContext()) { myContext.TABLE_NAME.FirstOrDefault(x = > x.id == 1 ).名称= " ; myContext.SaveChanges(); }
Hi,
This is my Sql query (update TABLE NAME set Name=''XXXX'' where Id=1) how to write this in Linq Plz help me im new to Linq.
解决方案
Hi,
See the below link. It might be help you.
http://atikpassion.blogspot.in/2011/10/c-linq-insertupdate-delete-does-exist.html[^]
http://rochcass.wordpress.com/2011/03/11/linq-to-sql-simple-insert-update-and-delete/[^]
Thanks,
Viprat
http://msdn.microsoft.com/en-us/library/bb386931.aspx[^]
http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx[^]
using (var myContext = new DataContext()) { myContext.TABLE_NAME.FirstOrDefault(x=> x.id== 1).Name = "New Name"; myContext.SaveChanges(); }
这篇关于需要SQL查询到Linq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文