Linq to sql query to return data from table

Posted by Jopito under ASP.NET on 1/20/2014 | Points: 10 | Views : 674 | Status : [Member] | Replies : 2
Hi,have got a linq query to retutn data from table in my databse.I can see that it picks the columns i need returned but cannot display the data.I have a method to query that and i would appreciate if someone tells me whats wronng with my query below.Here is the query and method.Am filling the comboboxes on page load directly from the database.Here is the code.i cant figure whats wrong with this query really

public List<Student> GetStudentsData(int studentId,int schoolId  ,int admissionNumber)
{


var query = from students in db.students

where students .studentId== studentId
where students .admissionNumber== admissionNumber
where students .schoolId== schoolId

select students ;


return query.ToList();


Mark as answer if satisfied


Responses

Posted by: Sravan661 on: 1/20/2014 [Member] Bronze | Points: 25

Up
0
Down
Try this

public List<Student> GetStudentsData(int studentId,int schoolId  ,int admissionNumber)

{





var query = from students in db.students



where students .studentId== studentId

and students .admissionNumber== admissionNumber

and students .schoolId== schoolId



select students ;





return query.ToList();


sravan

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

Posted by: Rajesh_Kumar on: 1/20/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
Use and in where condition instead of so many where clauses.

Rejesh Kumar

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

Login to post response