大佬教程收集整理的这篇文章主要介绍了在SQL Server 2014中写入基础表后立即查询视图,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是视图的定义:
create view [Position].[transactions] WITH scheR_215_11845@ABINDING AS ( SELECT Account,Book,Timeapiclient AS datetiR_215_11845@eUtc,BaseCcy AS Currency,ISNULL(QuantityBase,0) AS Quantity,ValueDate AS SettleDate,ISNULL(CAST(0 AS Tinyint),0) AS transactiontype FROM Trades.FxSpotMF WHERE IsCancelled = 0 union all SELECT Account,QuoteCcy AS Currency,ISNULL(-QuantityBase * Rate,ExecutionTimeUtc AS datetiR_215_11845@eUtc,ISNULL(CAST(1 AS Tinyint),1) AS transactiontype FROM Trades.FxSpotManual WHERE IsCancelled = 0 union all SELECT Account,ISNULL(SpotQuantityBase,SpotValueDate AS SettleDate,ISNULL(CAST(2 AS Tinyint),2) AS transactiontype FROM Trades.FxSwap union all SELECT Account,ISNULL(-SpotQuantityBase * SpotRate,ISNULL(ForWARDQuantityBase,ForWARDValueDate AS SettleDate,ISNULL(-ForWARDQuantityBase * ForWARDrate,c.book,TimeUtc AS datetiR_215_11845@eUtc,Currency,ISNULL(amount,SettleDate,ISNULL(CAST(3 AS Tinyint),3) AS transactiontype FROM Trades.Commission c JOIN Trades.Payment p ON c.UniquePaymentId = p.UniquePaymentId AND c.book = p.book )
而这是Linq-to-sql生成的用于写入其中一个基础表的查询:
INSERT INTO [Trades].[FxSpotMF] ([UniqueTradEID],[BaseCcy],[QuoteCcy],[ValueDate],[Rate],[QuantityBase],[Account],[Book],[CounterpartyId],[Counterparty],[ExTradEID],[Timeapiclient],[TimeAPIServer],[TimeExchange],[TimeHandler],[UniqueOrderId],[IsCancelled],[ClientId],[SequencEID],[ExOrdId],[TradeDate],[OrderCyclEID],[CycleIndex]) VALUES (@p0,@p1,@p2,@p3,@p4,@p5,@P6,@P7,@p8,@p9,@p10,@p11,@p12,@p13,@p14,@p15,@p16,@p17,@p18,@p19,@p20,@p21,@p22)
这是Linq-to-sql产生的查询查询效果的查询:
SELECT SUM([t0].[Quantity]) AS [Item2],[t0].[Currency] AS [Item1] FROM [Position].[transactions] AS [t0] WHERE ([t0].[Book] = @p0) AND ([t0].[datetiR_215_11845@eUtc] < @p1) GROUP BY [t0].[Currency]
此外,这是生成写入(使用F#类型提供程序)的Linq-to-sql代码:
type scheR_215_11845@a = Microsoft.fsharp.data.typeproviders.DbmlFile<"TradeDb.dbml",ContextTypename="TradeDb"> use db = new scheR_215_11845@a.TradeDb(connectionString) let Trade = new scheR_215_11845@a.Trades_FxSpotMF() (* omitted: set object properties corresponding to column values here... *) db.Trades_FxSpotMF.InsertOnSubmit(TradE) db.SubmitChanges()
而这是生成读取的相应Linq-to-sql:
use db = new scheR_215_11845@a.TradeDb(connectionString) query { for t in db.Position_transactions do where ( t.book = book && t.datetiR_215_11845@eUtc < df.MaxExecutionTimeExcl ) groupBy t.Currency into group let @R_849_10586@l = query { for x in group do sumBy x.Quantity } SELEct (group.Key,@R_849_10586@l) } |> Map.ofSeq
我会以为System.Data.Linq.DataContext.SubmitChanges()只会在写入事务完成后返回,并且视图的任何后续查询都必须包含写入的效果…我缺少/做错了什么?
以上是大佬教程为你收集整理的在SQL Server 2014中写入基础表后立即查询视图全部内容,希望文章能够帮你解决在SQL Server 2014中写入基础表后立即查询视图所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。