Unable to cast object of type 'System.Data.Linq.DataQuery`1[Customer]' to type 'System.Data.D...

Depending on your requirements and current implementation, you could also return a list of your custom type (Customers) - that will also change:

- your method signature
- references to that method and your code that processes a DataTable instead, at the receiving end
..as such these are part of a larger 'layer' etc
Re: Unable to cast object of type 'System.Data.Linq.DataQuery`1[Customer]' to type 'System.Data.D...
Unable to cast object of type 'System.Data.Linq.DataQuery`1[Customer]' to type 'System.Data.D...

public List<Customers> ServiceRequestStatus()
{
      .
      .      .
      var servicerequest = from cust in dc.Customers
                                    where cust.CustomerID == customerid
                                    select cust;

      return servicerequest.ToList();     
 }                         
:) so now, whether you do .ToList() or call an inline extension method, its up to you. 

0 Responses to “Unable to cast object of type 'System.Data.Linq.DataQuery`1[Customer]' to type 'System.Data.D...”

Post a Comment

Labels

Topics