如何在LINQ中更新字段 [英] How to update Fields in LINQ
问题描述
先生
PriceUpdation.aspx页面具有一个文本框和一个按钮
在数据库中,我有一个包含两个字段的表
1)产品价格
2)最终产品价格
在按钮上单击---我们将在该文本框中输入的百分比%就像15%一样,将计算产品价格的15%,并将计算出的百分比添加到最终产品价格中..
我与LINQ有关的所有内容
我可以用LINQ更新两个列...我的表有23个字段.. ??
ANS asap =======================非常感谢您答复
Sir
the PriceUpdation.aspx page has a Textbox and a button
and in database i have a table having two Fields
1) Product Price
2) Final Product Price
on the click of button --- THE percentage % we will enter in that textbox like 15% it will callculate the 15% of Product Price and add that calcluted % to the Final Product Price ..
All This i have to do with LINQ
Can i update two coloumns by LINQ ... my table has 23 Fields .. ??
ANS asap ======================= Thanks alot for replying
推荐答案
是的.您可以从数据库上下文设置属性中获取对象,然后在上下文对象上调用SubmitChanges
提交更改.顾志刚(Scott Gu)对此有很好的文章
使用LINQ to SQL(第1部分) [ ^ ]
您正在存储计算所得的字段,可能最好存储百分比并重新计算上面的两个属性.当然,这取决于您的应用程序的性质!
Yes you can. You get the object from the database context set the properties, then callSubmitChanges
on the context object to submit the changes. Scott Gu has a good article on this
Using LINQ to SQL (Part1)[^]
You are storing calculated fields, it might be better to store the percentage and re-calculate the two properties you have above. This depends upon the nature of your application of course!
这篇关于如何在LINQ中更新字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!