Click here to Skip to main content
14,428,118 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




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