Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public Table1 search()
 {

     Table1 t = new Table1();

     var qq = from c in DataBase.Table1s select c;


     return qq;//Error Cannot Convert????how to resolve this

 }
Posted
Comments
Santhosh Kumar Jayaraman 10-Aug-12 2:06am    
Do you want all row in the table??

You are returning Table1 in your function signature. So, try casting the return var 'qq' to Table1. Like return (Table1)qq;You are returning Table1 in your function signature. So, try casting the return var 'qq' to Table1. Like "return (Table1)qq;"
 
Share this answer
 
Comments
Seyed Ahmad Mirzaee 10-Aug-12 2:14am    
i try youre code but Error comes!!
I think Table1 is an entity in your model. You have to select a row from the table to return it.

Try this

C#
private Table1 Result()
{
Table1 t = new Table1();
t =
DataBase.Table1s.Single(k=>k.Id>0);
 
}
 
Share this answer
 
Comments
Seyed Ahmad Mirzaee 10-Aug-12 2:24am    
no!!!
Error not resolve
thanks
Santhosh Kumar Jayaraman 10-Aug-12 2:33am    
What u r getting now? are u getting error for above code?
hey ,
you are trying to return multiple tables

from c in DataBase.Table1s select c;

this statement will return list of tables just
modify your code with


C#
public Table1 search()
 {

     Table1 t = new Table1();

     t  = (from c in DataBase.Table1s select c).ToList().FirstOrDefault();


     return t;//Error Cannot Convert????how to resolve this

 }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900