0

I want to split a string like Members in table Set and select the result with other fields as a record.

For example, lets assume the Set has 2 fields (ID, Members) and 2 records: (1, "A, B") and (2, "C").

Now I need a Linq query to retrieve records as: (1, A), (1, B), (2,C).

I am using Visual Studio 2008.

1 Answer 1

1

LINQ-to-SQL won't do this, but you can retrieve this data using LINQ-to-SQL and then run straight LINQ against it.

List<Set> sets;
using (var context = new MyDataContext())
{
    sets = context.Sets.ToList();
}

var result = sets.SelectMany(s => 
    s.Members.Split(',').Select(m => new { s.ID, m }));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.