Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 977313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:52:59+00:00 2026-05-16T03:52:59+00:00

I have the following table structure: CREATE TABLE [Report].[MesReport]( [MesReportID] [int] IDENTITY(1,1) NOT NULL,

  • 0

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> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:52:59+00:00Added an answer on May 16, 2026 at 3:52 am

    The trick here is that you need two separate LINQ statement, one linq-to-sql to read the data, and one linq-to-xml to write it.

    var reportdata = from r in db.MesReport
    //               where r.whatever ......
                    select r;
    
    var reportXmlItems = from rx in reportData
                   select new XElement("MesReport", 
                        new XElement("ReportTitle", rx.ReportTitle),
                        new XElement("ReportName", rx.ReportName
                        new XElement("DatabaseServer", rx.DatabaseServer
                        new XElement("Database", rx.Database
                        new XElement("Login", rx.Login
                        new XElement("MesReportId", rx.MesReportId
                        new XElement("ParentId", rx.ParentId)
                    );
    
     var reportXml = new XElement("MesReports", reportXmlItems);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table structure CREATE TABLE `table` ( `id` int(11) NOT NULL
I have the following table structure: CREATE TABLE a ( a_id int(10) unsigned NOT
I have the following database structure: CREATE TABLE `author` ( `id` int(10) unsigned NOT
I have the following structure: CREATE TABLE IF NOT EXISTS `myTable` ( `ID` int(11)
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I have the following table structure in my database: create table Encargado( ID int
I have following table structure: CREATE TABLE pilot_groups ( id INT PK, name VARCHAR(50),
Given the following table structure: CREATE TABLE IF NOT EXISTS `roles` ( `id` int(11)
I have the following data structure and data: CREATE TABLE `parent` ( `id` int(11)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.