Linq如果在另一张表中插入了新行,则更新一行 [英] Linq Update a row if new rows are inserted in another table
问题描述
我这里有4个表,当我使用linq将新行添加到另一个表中时,我正在尝试更新最后一个条目行.
I have 4 tables here, I am trying to update last entry row when new rows are added in another table using linq
CustomerTable :
CustomerId Name EmailId
-------------------------
1 Paul r@r.com
2 John J@j.com
在下表中,我为每个LoyatyType分配了点数
Below table I am assigning points for each LoyatyType
LoyaltyPointTable :
LoyaltyPointsId LoyaltyType Points
---------------------------------------
1 Registration 10
2 Loginstatus 1
3 Downloading 10
4 Redemming 1
5 Sharing 20
6 Refer 10
忠诚度详细信息表:
LoyaltyDetailsId LoyaltyPointsId CustomerId Dates
-------------------------------------------------
1 1 1 2015-01-22
2 2 1 2015-01-22
3 3 2 2015-01-22
4 3 1 2015-01-22
5 4 1 2015-01-22
6 4 1 2015-01-24
7 2 1 2015-01-24 // here one new row is added based on LoginStatus
他已经完成了登录一次,所以他的LoginStatus点现在为1,我想在下面的另一张表中更新该点
he has done Login one time , so his LoginStatus Point is 1 now I want update this point in another table below
预期输出:
PriceClaimTable
PriceClaimId CustomerId PriceId Current Points
1 2 22 150
2 1 23 200 // here update the last row of CustomerId as 231
//based on every new entry on LoyaltyDetailsTable
说他是否再次登录200 + 1 = 201
然后他正在下载201 + 10 = 211
然后他确实共享211 + 20 = 231
Say if he Logins again 200 + 1 = 201
Then he is Downloading 201 + 10 = 211
Then he does sharing 211+20 = 231
我可以在Linq中使用sql触发器并为此找到解决方案吗?
can i use sql triggers in Linq and find a solution for this ?
推荐答案
使用可以使用triggers
来完成这项工作.您可以此来编写一个.
Use can use triggers
for doing this job. You can look this for writing one.
这篇关于Linq如果在另一张表中插入了新行,则更新一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!