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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:35:33+00:00 2026-05-26T00:35:33+00:00

I have a C# .net 3.5 application using an ADO.NET Entity Data Model. I

  • 0

I have a C# .net 3.5 application using an ADO.NET Entity Data Model. I am loading the contents for a given database entry from an XML file.
What’s the best method to convert a List<String> from the XML to an EntityCollection<>?

The XML looks like this:

<Task>
    <Name>Test Task</Name>
    <SerialNumbers>
        <Serial>12345678901</Serial>
        <Serial>98765432101</Serial>
    </SerialNumbers>
</Task>

The database looks like this:

task { [int, pk]TaskID }
criteria_serialnumber { [int, pk]SerialNumberID, [string]SerialNumber }
task_serialnumber { [int, pk]SerialNumberID, [int, pk]TaskID }

The C# code looks like this:

using (XmlTextReader xml = new XmlTextReader(task_file))
{
    XElement x = XElement.Load(xml);

    // this works great.
    task.Name = x.Element("Name").Value;

    // How do I convert from List<String> to EntityCollection<criteria_serialnumber> ? 
    task.SerialNumbers = (from i in x.Element("SerialNumbers").Elements("Serial") select i.Value).ToList();
}
  • 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-26T00:35:33+00:00Added an answer on May 26, 2026 at 12:35 am

    You do not need to convert a List<string> to a EntityCollection<criteria_serialnumber>. You simply have to add each element to the existing EntityCollection:

    var serialNumbers = x.Element("SerialNumbers").Elements("Serial")
                         .Select(sn => sn.Value).ToList();
    
    foreach (var serialNumber in serialNumbers)
        task.SerialNumbers.Add(new SerialNumber { SerialNumber = serialNumber });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables
I have a asp.net application in that I am using ado.net entity framework in
I have been using ADO.net since 2002/2003 and most of the application I have
I have written a small Asp.net application using Entity Framework. A Stored Procedure accepts
I have an ASP.NET MVC 3 Web Application using Linq-to-SQL for my data access
I have an OData WCF ADO.NET service created with Entity Framework using protocol version
I have a .NET application, which is using an open source C++ compression library
I have a .NET client application that needs to communicate with a server using
I have to develop an application using C#.net that has to be run once
I have a web application using ASP.NET 2.0 and I want to know if

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.