Search code examples
c#asp.netlinqdatatableobjectdatasource

How to use Linq Query in Object Data Source?


If I have the following query code :

DataTable loans =Loans_HR.CalcLoans(2011, 7, 2013);
var groupedData = from b in loans.AsEnumerable()    
                  group b by b.Field<int>("loan_code") & b.Field<int>("emp_num") into f
                  select f.CopyToDataTable();

Now I want to use the groupedData As a result in my ObjectDataSource How to do that ?


Solution

  • Try this:

    group b by new {b.Field<int>("loan_code"), b.Field<int>("emp_num")}
    

    P.S. Perhaps, you must use some aggregates.