【问题标题】:MS Enterprise Library Data Block to pass XML into the a stored procedure with a XML parameterMS 企业库数据块将 XML 传递到带有 XML 参数的存储过程
【发布时间】:2009-12-17 19:01:24
【问题描述】:

在我的应用程序中,我通常使用企业库数据块来简化我的数据库交互。 C#代码如:

public static IDataReader AdminNavigation_Insert(int iGroupId, string sText, string sRelativeUrl, int iSortOrder)
{ 
  return DatabaseFactory.CreateDatabase("database").ExecuteReader(
        "cms_uspAdminNavigation_Insert", 
        iGroupId, 
        sText, 
        sRelativeUrl, 
        iSortOrder);
}

将插入到存储过程中,例如:

ALTER PROCEDURE [dbo].[cms_uspAdminNavigation_Insert]
    @GroupId int,
    @Text nvarchar(500) = NULL,
    @RelativeUrl varchar(100) = NULL,
    @SortOrder int
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO dbo.cms_tblAdminNavigation (
    GroupId, Text, RelativeUrl, SortOrder, TsCreated, TsUpdated
) VALUES (
    @GroupId, @Text, @RelativeUrl, @SortOrder, getDate(), getDate()
);
SELECT @@IDENTITY;
END

现在,如果其中一个存储过程参数是 xml,我将使用什么 C# 数据类型通过企业库传递给该存储过程?

【问题讨论】:

    标签: c# xml sql-server-2005 stored-procedures enterprise-library


    【解决方案1】:

    字符串 = SQLDbBtype.xml

    C#/SQL - What’s wrong with SqlDbType.Xml in procedures

    Or another SO question

    编辑,但是对于Linq,它可能是 System.Xml.Linq.XElement

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-19
      • 2010-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多