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 6552671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:29:18+00:00 2026-05-25T12:29:18+00:00

I have a Linq List in which have data more than one tables and

  • 0

I have a Linq List in which have data more than one tables and these tables has related to each other. in this list it has some another table list property. Like table1 and table2 has related to each other and we have a data in list of table1 and in this list it has automatically table2 data.

Now i want to convert this List into a XML but it throws an error i.e. circular reference error, So now i want to convert this list into a dataset and by using this dataset i can generate a xml.

So can anyone provide us code to generate multiple tables dataset from a List….

or

convert list to xml code….

or

any other helpful comments…………

  • 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-25T12:29:19+00:00Added an answer on May 25, 2026 at 12:29 pm

    You really haven’t given a lot of information to work with, but I’ll take a stab at a basic answer.

    Given this class structure:

    public class Table1
    {
        public string Value;
        public Table2 Table2;
    }
    
    public class Table2
    {
        public string Value;
    }
    

    I can create this list:

    var lsttable1 = new List<Table1>()
    {
        new Table1()
        {
            Value = "Foo1",
            Table2 = new Table2()
            {
                Value = "Bar1",
            },
        },
        new Table1()
        {
            Value = "Foo2",
            Table2 = new Table2()
            {
                Value = "Bar2",
            },
        },
    };
    

    Now, I might want to convert this into XML that looks like this:

    <Table1s>
      <Table1 Value="Foo1">
        <Table2 Value="Bar1" />
      </Table1>
      <Table1 Value="Foo2">
        <Table2 Value="Bar2" />
      </Table1>
    </Table1s> 
    

    Here’s the LINQ code that does it:

    var xd =
        new XDocument(
            new XElement(
                "Table1s", 
                from t1 in lsttable1
                select new XElement(
                    "Table1",
                    new XAttribute("Value", t1.Value),
                    new XElement(
                        "Table2",
                        new XAttribute("Value", t1.Table2.Value)
                    )
                )
            )
        );
    

    Is that the kind of thing that you wanted?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some LINQ code that generates a list of strings, like this: var
I have a LINQ to SQL query which produces an object of type {System.Data.Linq.DataQuery}.
I have a list of floating point data in which I want to find
I have a list of files (stored in db which I get using Linq),
This turned out to be more difficult than I thought. Basically, each day a
I have this much: A table which used to store the Folders. Each folder
I have people and places data as: Person entity has IList<DateRangePlaces> each having IList<Place>
I have the following LINQ query: List<string> Types = (List<string>)Directory.GetFiles(@C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727) .Where(x => System.IO.Path.GetFileNameWithoutExtension(x).Contains(Microsoft)) .ToList<string>();
I have a LINQ query to a DataTable : var list = from row
I have some Linq code, that works fine. It retrieves a list of board

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.