【发布时间】:2010-10-20 23:31:29
【问题描述】:
使用以下逻辑,单个 LINQ 查询的正确语法是什么?
If Branch is Service, I want its parent, otherwise I want Branch.
您能否批评我的尝试并告诉我如何改进它?
int branchId = 21;
var t = ctx.BranchInfos.Single(p => p.BranchID == branchId );
if (t.Type == BranchType.Service.ToString())
{
t = ctx.BranchInfos.Single(p => p.BranchID == t.Parent);
}
【问题讨论】: