如何在没有数据的情况下插入记录,或者在linq中有条件的情况下更新记录 [英] how to insert records if no data or update if have records with condition in linq

查看:130
本文介绍了如何在没有数据的情况下插入记录,或者在linq中有条件的情况下更新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,

示例:

dear sir,

Example:

if exists (select * from table_name where key = @key)
begin
   update table set ...
   where key = @key
end
else
begin
   insert table (key, ...)
   values (@key, ...)
end



我想要LINQ概念中的此查询.
如何获取代码.


带有评分
通过mohan.



I want this query in LINQ concepts.
how to get code.


With Regrads
By mohan.

推荐答案

我可以很容易地获得数据,并为您做..

这是linq的基础知识.
http://www.deitel.com/ResourceCenters/Programming/MicrosoftLINQ/Tutorials/tabid/2673/Default.aspx [ ^ ]


希望对您有所帮助!
it''s pretty easy can i have the data and i''ll do it for you ..

here''s the basics of linq.
http://www.deitel.com/ResourceCenters/Programming/MicrosoftLINQ/Tutorials/tabid/2673/Default.aspx[^]


hope it helps!


这篇关于如何在没有数据的情况下插入记录,或者在linq中有条件的情况下更新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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