Click here to Skip to main content
15,860,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how i can get perticular id record in dbset<model> in context
Posted
Comments
Lakhan Anjana 15-Jul-15 2:51am    
var Data= from c in db.tablename where c.id==ID select c
C. Nakul 15-Jul-15 3:06am    
ya, it's ok but i want to perticular id record in dbset<Profile> in context file,
it shows all the record in Profile table.
thanks,
Er Daljeet Singh 15-Jul-15 3:18am    
As Lakhan Anjana told if you want to Fecth the ID then Simply Write
var Data= from c in db.tablename where c.id==ID select c.id;
Or u can write

List<int> list=db.Profile.Select(m=>m.ID).ToList();
It Will return u the list of Id from the Profile table.
C. Nakul 15-Jul-15 3:22am    
my dbset<Profile> contain large records, i can access particular record in repository, but i want retrieve single record in dbset<Profile> at the time of execute of context file.
Er Daljeet Singh 15-Jul-15 3:53am    
if u want to fetch Single Record then Write
var Data= (from c in db.Profilewhere c.id==ID select c.id).SingleOrDefault();
this will return you the object of Type Profile

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