error Cannot implicitly convert type 'System.Linq.IQueryable<Threetierexample.ClsCustomer>' to 'System.Data.Linq.Table<Threetierexample.ClsCustomer>'. An explicit conversion exists (are you missing a cast?)

Posted by Klbaiju under Regular Expressions on 9/7/2009 | Views : 8546 | Status : [Member] | Replies : 1
hi when i build the solution this error showing
error Cannot implicitly convert type 'System.Linq.IQueryable<Threetierexample.ClsCustomer>' to 'System.Data.Linq.Table<Threetierexample.ClsCustomer>'. An explicit conversion exists (are you missing a cast?)

this is the code
public Table<ClsCustomer> getdetails(out string msg)
{
// customer;
try
{
Table<ClsCustomer> customer = Db.GetTable<ClsCustomer>();
var query = from c in customer
where c.CustomerCode == "333"
select c;
msg = "Success";
return query;
}
catch (Exception ex)
{
msg = ex.Message;
return null;
}


}
i want to pass the value of query




Responses

Posted by: Rtpharry on: 9/7/2009 [Member] [MVP] Bronze

Up
0
Down
Hey, this is because the table would be several rows of data but your var query = .... is asking for a single record which would just be a ClsCustomer.

If you hover over the var keyword it says what type it is. Set that to the return type of your getdetails() method.

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response