Click here to Skip to main content
13,141,637 members (55,244 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 5-Aug-12 18:49pm
Updated 5-Aug-12 21:14pm
v3
Comments
Santhosh Kumar J 6-Aug-12 3:24am
   
have u tried solution 1?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

private Table1 Result()
{
Table1 t = new Table1();
t =
DataBase.Table1s.Single(k=>k.Id>0);
 
}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi,
Try this:
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
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100