我有4代表在這裏,我試圖更新時,新的行與另一個表中使用LINQLINQ的更新行,如果新行插入另一個表
CustomerTable的添加最後一項排:
:CustomerId Name EmailId
-------------------------
1 Paul [email protected]
2 John [email protected]
下表我對每個LoyatyType
LoyaltyPointTable分配點
LoyaltyPointsId LoyaltyType Points
---------------------------------------
1 Registration 10
2 Loginstatus 1
3 Downloading 10
4 Redemming 1
5 Sharing 20
6 Refer 10
LoyaltyDetailsTable:
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,現在我想在下面更新另一個表中這一點
預期輸出:
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
我可以使用sql在LINQ和觸發找到解決方案?
您正在使用哪些DBMS? Postgres的?甲骨文? – 2015-02-10 13:33:05
我正在使用Sqlserver 2012 – stom 2015-02-10 13:36:53