Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
153 views
in Technique[技术] by (71.8m points)

Different columns select for each object in linq

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...