I have the following table structure:
CREATE TABLE [Report].[MesReport](
[MesReportID] [int] IDENTITY(1,1) NOT NULL,
[ParentID] [int] NOT NULL,
[ReportTitle] [nvarchar](80) NOT NULL,
[ReportName] [nvarchar](80) NOT NULL,
[DatabaseServer] [nvarchar](80) NOT NULL,
[DatabaseName] [nvarchar](50) NOT NULL,
[Login] [nvarchar](80) NOT NULL,
[ReportFile] [varbinary](max) NULL
I want to create a Linq query that will query this table and generate the following XML. Can someone help with this?
<MesReports>
<MesReport>
<ReportTitle>Mes to Sap Reconciliation Reports</ReportTitle>
<ReportName>None</ReportName>
<DatabaseServer>None</DatabaseServer>
<Database>None</Database>
<Login>None</Login>
<MesReportId>1</MesReportId>
<ParentId>-1</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Finished Goods</ReportTitle>
<ReportName>None</ReportName>
<DatabaseServer>None</DatabaseServer>
<Database>None</Database>
<Login>None</Login>
<MesReportId>2</MesReportId>
<ParentId>1</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Semi-Finished Goods</ReportTitle>
<ReportName>None</ReportName>
<DatabaseServer>None</DatabaseServer>
<Database>None</Database>
<Login>None</Login>
<MesReportId>3</MesReportId>
<ParentId>1</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Warranty Reports</ReportTitle>
<ReportName>None</ReportName>
<DatabaseServer>None</DatabaseServer>
<Database>None</Database>
<Login>None</Login>
<MesReportId>4</MesReportId>
<ParentId>-1</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Box - PBG</ReportTitle>
<ReportName>Warranty Box - PBG</ReportName>
<DatabaseServer>MyServer</DatabaseServer>
<Database>MESProduction</Database>
<Login>6QDI+IoQbkZKJpVBcRJcNtoqR62606Q2</Login>
<MesReportId>5</MesReportId>
<ParentId>4</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Box - FFO</ReportTitle>
<ReportName>Warranty Box - FFO</ReportName>
<DatabaseServer>MyServer</DatabaseServer>
<Database>MESProduction</Database>
<Login>6QDI+IoQbkZKJpVBcRJcNtoqR62606Q2</Login>
<MesReportId>6</MesReportId>
<ParentId>4</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Bin Count - PBG</ReportTitle>
<ReportName>Bin Count - PBG</ReportName>
<DatabaseServer>MyServer</DatabaseServer>
<Database>MESProduction</Database>
<Login>6QDI+IoQbkZKJpVBcRJcNtoqR62606Q2</Login>
<MesReportId>7</MesReportId>
<ParentId>4</ParentId>
</MesReport>
<MesReport>
<ReportTitle>Bin Count - FFO</ReportTitle>
<ReportName>Bin Count - FFO</ReportName>
<DatabaseServer>MyServer</DatabaseServer>
<Database>MESProduction</Database>
<Login>6QDI+IoQbkZKJpVBcRJcNtoqR62606Q2</Login>
<MesReportId>8</MesReportId>
<ParentId>4</ParentId>
</MesReport>
</MesReports>