我有这个存储过程:
CREATE PROCEDURE [RSLinxMonitoring].[InsertFeatures]
@Features nvarchar(50),
@TotalLicenses int,
@LicensesUsed int,
@ServerName nvarchar(50)
AS
SET NOCOUNT ON
INSERT INTO [RSLinxMonitoring].[FeatureServer]
([Features]
,[TotalLicenses]
,[LicensesUsed]
,[Server])
VALUES(@Features
,@TotalLicenses
,@LicensesUsed
,@ServerName)
它按预期工作,但由于我需要从我的 C# Linq-to-SQL 类中插入退出,我想从我的应用程序中插入一个列表,这可能吗?
It works as expected, but since I need to insert quit a bit from my C# Linq-to-SQL class, I would like to insert a list from my application instead, is this possible?
我已经看到它是在使用 SELECT
语句时完成的,但在使用 INSERT
时没有.
更新:由于 LINQ to SQL 不支持用户定义的表类型,因此我不能创建表.:(
I have seen it been done then using SELECT
statement, but not when using INSERT
.
UPDATE:
Since LINQ to SQL Doesn't support User-Defined Table Types i can't Tables. :(
如果您使用的是 SQL Server 2008 &以上,您可以使用以下解决方案.声明表类型,如:
If you are using SQL server 2008 & above, you can use below solution. Declare Table type like :
CREATE TYPE FeatureServerType AS TABLE
(
[Features] nvarchar(50)
,[TotalLicenses] int
,[LicensesUsed] int
,[Server] nvarchar(50)
);
像这样使用:
CREATE PROCEDURE [RSLinxMonitoring].[InsertFeatures]
@TabletypeFeatures FeatureServerType READONLY
AS
SET NOCOUNT ON;
INSERT INTO [RSLinxMonitoring].[FeatureServer]
([Features]
,[TotalLicenses]
,[LicensesUsed]
,[Server])
SELECT * FROM @TabletypeFeatures
这篇关于使用 LIST 插入存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!