Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: LINQ
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
Edited 5-Aug-12 21:14pm
v3
Comments
Santhosh Kumar J at 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 at 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
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 450
1 Sergey Alexandrovich Kryukov 350
2 Shai Vashdi 318
3 OriginalGriff 265
4 Peter Leow 171
0 Sergey Alexandrovich Kryukov 9,109
1 OriginalGriff 5,290
2 Peter Leow 4,010
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid