开发者

how to query in linq to sql such way?

开发者 https://www.devze.com 2023-01-15 04:30 出处:网络
I want to select the user. For this user I am marinating the designation Id which is foreign key in user table. as well as I am maintaining theActiveStatus for soft delete. I want to select t开发者_运

I want to select the user. For this user I am marinating the designation Id which is foreign key in user table. as well as I am maintaining the ActiveStatus for soft delete. I want to select t开发者_运维技巧he user who are active , but instead of designation Id it must show designation name (like Director, Manager ..so on). How to join 2 tables and get result in linq to sql . I am using ASP.NET + C#.


I suppose you have a designation table with DesignationId and Name, with the DesignationId as a FK to the user table.

from user in users
where user.ActiveStatus == "Active" // or whatever
select new {Name = user.Name, DesignationName = user.Designation.Name}
0

精彩评论

暂无评论...
验证码 换一张
取 消