繁体   English   中英

如何在XElement上放置命名空间别名? 如何将数据源添加到现有RDL文档?

[英]How do you place namespace alias on an XElement? How do you add a datasource to existing RDL document?

我正在尝试创建一个数据源的XElement插入到SSRS RDL文件中。 但是,我似乎无法让它在rd:别名方面正确创建。 这是我正在使用的代码。

XNamespace rootNs = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition";
XNamespace rdNs = "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner";
XElement _dataSource = new XElement("DataSource",                            
             new XAttribute(XNamespace.Xmlns + "rd", rdNs),
             new XAttribute("Name", "eFinancials_LOCAL"),
             new XElement("ConnectionProperties", new XElement("DataProvider", "SQL"), new XElement("ConnectString", connectionString)),
             new XElement(_rdns + "SecurityType", "DataBase"),
             new XElement(_rdns + "DataSourceID", dataSourceId)
                                            );

产生的XML元素是:

<DataSource xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" Name="eFinancials_LOCAL">
  <ConnectionProperties>
    <DataProvider>SQL</DataProvider>
    <ConnectString>Data Source=.;Initial Catalog=800_LMS_eFin_Deploy</ConnectString>
  </ConnectionProperties>
  <SecurityType xmlns="rd">DataBase</SecurityType>
  <DataSourceID xmlns="rd">56e5e869-6ca5-44f9-8340-22821177569e</DataSourceID>
</DataSource>

但是,它需要是:

<DataSource Name="eFinancials_LOCAL">
  <ConnectionProperties>
    <DataProvider>SQL</DataProvider>
    <ConnectString>Data Source=.;Initial Catalog=800_LMS_eFin_Deploy</ConnectString>
  </ConnectionProperties>
  <rd:SecurityType>DataBase</SecurityType>
  <rd:DataSourceID>56e5e869-6ca5-44f9-8340-22821177569e</DataSourceID>
</DataSource>

如何调整我的代码以创建如上所述的正确XML? 我几乎到了我要将其创建为文本的地步。

XNamespace ns = @"http://www.somesite.com/xml/customer/2006-10-31";
XElement xe = new XElement(ns + "customers", 
   new XAttribute("xmlns", ns),
   new XElement(ns + "customer", new XElement(ns + "firstname", customer.FirstName); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM