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


Related Query

More Query from same tag