本文介绍了使用单个查询在多个表中插入记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用LINQ在asp.net中开发Web应用程序.我正在寻找一种解决方案,以单个查询在多个表中插入记录.

例如.我有三个相互关联的表.

Hi All,

I am developing web application in asp.net by using LINQ. I am looking for solution to insert records in multiple tables with single query.

E.g. I have three tables which has relations with each other.

TableA
ColAA (Primary Key)
ColAB
ColAC Foreign Key with C);

TableB
ColBA (Primary Key)
ColBB
ColBC(Foreign Key with A);

TableC
ColCA (Primary Key)
ColCB
ColCC(Foreign Key with B);


同时,我将在同时必须在TableB和TableC中插入记录的同时在TableA中插入记录.我不想使用代码进行数据库服务器的三趟旅行,也不想在单个存储过程中执行三个查询

有效执行此操作的最佳策略是什么?

问候!
Aman


While, I will insert record in TableA in the mean time I have to insert records in TableB and TableC. I do not want to make three trip of database server with code or execute three queries in single stored procedure

What is the Best policy to do it efficiently?

Regards!
Aman

推荐答案



这篇关于使用单个查询在多个表中插入记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 03:31