0

SSRS RDL ファイルに挿入するデータソースの XElement を作成しようとしています。ただし、 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 を作成するようにコードを調整するにはどうすればよいですか? テキストとして作成するところまで来ました。

4

1 に答える 1

2
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); 
于 2013-05-03T19:43:26.173 に答える