Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private Table1 Result() 
{
   Table1 t = new Table1();
    var q =
        from k in DataBase.Table1s
       where k.Id>0
        select k;
t = q;//Erorr!! How To Resolve This Section.With Cast Also is Not Resolve

return t;
 }


I have one table.it Name is Table1
I want to Return Result this Query with Table1 Objects?
but I Dont Know!!!
Posted
Updated 5-Aug-12 21:14pm
v3
Comments
Santhosh Kumar Jayaraman 6-Aug-12 3:24am    
have u tried solution 1?

C#
private Table1 Result()
{
Table1 t = new Table1();
t =
DataBase.Table1s.Single(k=>k.Id>0);

}
 
Share this answer
 
Hi,
Try this:
C#
private Table1 Result()
{
    // Suppose your DataContext class name is TestDataContex. 
    TestDataContext ctx = new TestDataContext();
    var Query =  from c in ctx.Table1s select c;
    // Now you got a query. Use it as required.
}


Refer Understanding LINQ (C#)[^] and Using LINQ to Objects in C#[^].


All the best.
--Amit
 
Share this answer
 
v2
Comments
Seyed Ahmad Mirzaee 7-Aug-12 2:23am    
With This Code Error Again Occured!!!
"Error:Can Not Convert System.data.linq.IQueryable<Table1> to 'Table1'.an Explpicit Conversion exist.are you missing cast?"

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