Click here to Skip to main content
15,885,878 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
one table is Users and another table is Property Details Builders. i want to join thus tables according to username.here is my controller code:

var query = from u in db.Users
join s in db.PropertyDetailsBuilders on u.UserName equals s.UserName
where u.UserName == s.UserName
select new
{
u.UserName,
u.FirstName,
u.LastName,
u.Role,
s.SubscriptionName,
s.Subscriptions,
s.PropertySubTypeName

};

return View(query.ToList());

how to design my view?iam using viewmodel
Posted

1 solution

Hai
r u use sql server ? if it is yes,u no need to write query,simple way is go to sql server ,open ur database and expand,in ur database u can see Tables,views,synonyms,programmability ect..,just right click Views,it open,then select what tables are need to join,and add tables in views click ok and then select the fields form both tables,after select fields,in belaow u see one query,simply u use that query.
 
Share this answer
 

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