score:2
Accepted answer
try something like this, utilizing navigation properties (you'll probably have to massage it as i don't know the exact makeup of your data structures):
var customerquery = context.customertable.select( ct =>
new {
ct.id,
ct.customertitle,
// use nav property to get customer payments
customerpayments = ct.customerpayments.select( cp =>
new {
range = cp.range,
values = cp.values } ) } );
return customerquery.toarray()
.select( cq =>
{
var retval = new scustomerinfo( createcustomertable(), cq.id, cq.customertitle );
foreach( var customerpayment in cq.customerpayments )
{
var dtrow = cq.paymenttable.newrow();
dtrow.itemarray = new object[] { customerpayment.range, customerpayment.values };
retval.paymenttable.rows.add( dtrow );
}
return retval;
} );
score:0
if i understand right in c# with linq it will be something like this
var customerinfos = customertitlesandids.select((c)=>{
var ci = new scustomerinfo(createcustomertable(), c.id, customer.customertitle);
ci.paymenttable = ci.paymenttable.asenumerable().union(
cutomeridpayment.where(j=>j.id == c.id)
.select(j=>{
var dtrow = ci.paymenttable.newrow();
dtrow.itemarray = new object[] {
customerpayment.range,
customerpayment.values
};
return dtrow;
})).copytodatatable();
return ci;
}).tolist();
score:0
i think you can use the linq provided function sequence.concat() as described here: http://msdn.microsoft.com/en-us/library/vstudio/bb386979(v=vs.100).aspx
Source: stackoverflow.com
Related Query
- How can I combine this code into one or two LINQ queries?
- How merge two sequences into one?
- How to merge two lists that share 1 attribute into a third one with LINQ?
- How to merge two lists of different types into one list of new type that contains both types?
- How to combine / merge two StringCollection into one in C#
- C# How do i merge two DataTable Row into one row
- How do I merge two LINQ statements into one to perform a list2.Except(list1)?
- How can I merge two LINQ queries into one query?
- Merge two List<object> into one List in Linq
- Merge two Lists in C# and merge objects with the same id into one list item
- How to Combine two Sum operations into one using LINQ?
- How can I split a List<T> into two lists, one containing all duplicate values and the other containing the remainder?
- How to use LINQ to combine two or more collections into one collection
- How to merge two classes into single unit?
- how to combine two data source into one?
- How can I code numerous MIN functions into one LINQ to DataSet query
- How to merge two lists while adding metadata indicating value source with LINQ statement?
- LINQ how to merge two columns in one column of query result
- Merge two LINQ expressions into one
- How to join two customer lists into one list
- How to Combine two object into one in C#
- How to combine two flat lists into one nested object
- how to insert two values manually into table by using code
- How to rewrite two loops into one LINQ statement
- How to put into linq lambda expression two opposite things but one has additional clause
- How to merge more than one list having objects into one list with sum of one of the elements of the list in c#
- How to merge XML node values into one node separated with a slash every 2 values
- How can i combine two object fields in Object List into one DropDown in mvc
- How can I Merge Two LINQ DataSources into a single table for a chart?
- How can I turn SQL query that joins two columns and groups by count of one column and a column of each joined table into LINQ?
More Query from same tag
- Query a list of objects that contains any string
- Binding Different LINQ datasource using same variable w/ if statement
- Join two tables in EntityFramework
- is it possible to pass a IIncludableQueryable object and apply it to a DbSet
- Given a Member Access lambda expression, convert it to a specific string representation with full access path
- Linq statement for Orders reporting
- Why does this LinQ query not like chars?
- Entity Framework LINQ Multiple Column Count(Distinct)
- MVC error "requires ienumerable instead of list"
- Create a Dynamic Linq to EF Expression to Select IQueryable into new class and assign properties
- Converting a IQueryable IEnumerable entity to a list
- How to filter the record with Entity Framework and display in datatables
- Skip first column and get distinct from other columns
- LINQ to get Distinct Count/Sort in List<List<string>>
- Linq To Entities Internal Conversion
- Linq avoid calling function twice
- How to serialize a ViewState objects
- LINQ Sort by Matching Character Position
- LINQ Use "like" instead of "(( NVL(INSTR(x, y), 0) ) = 1)"
- How to perform left join using two or more table in LInq to Sql query?
- Get the list of Child controls inside a groupbox
- Linq group by columns in a nested collection
- DataGridView shows type and not the value
- How to optimize this linq query to reduce the loops?
- Get all the child details in a xml?
- Linq to EF Include sub List for List
- How to group 2 different sequences in LINQ?
- Linq Full Outer Join on Two Objects
- populate dropdownlistfor mvc
- C# Linq execute method over results from Distinct() method