my object model is:
Link
I want to have a select on "Staff" table based on the definition access level in "TrusteeAccess" Table per user. In addition, the columns of the selected rows in "Staff" table are set according to "TrusteeAccessFields". In other words, if there isn't row in "TrusteeAccessFields" Table, the value of the column in "Staff" table is null.
public IEnumerable<StaffInfo> GetByUserAccess(User user)
{
IEnumerable<TrusteeAccess> trusteeAccsses = db.TrusteeAccesses.Where(ta => ta.UserId == user.UserId);
var results = db.StaffInfo.Where(s => trusteeAccsses.Any(t => t.StaffInfoId == s.StaffInfoId)).Select(/* Different Columns */).ToList();
return results;
}
Note1: For each column name in "Staff" Table, there is an object in "TrusteeAccessFields" Table.
Note2: The number of columns in "Staff" Table is large.
what is that linq query per user?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…