using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.Entities; using System.Linq.Expressions; namespace EMIS.DataLogic.SystemDAL { public class MenuDAL { public RoleRepository RoleRepository { get; set; } public UserRepository UserRepository { get; set; } public MenuRepository MenuRepository { get; set; } public IQueryable GetMenuByUser( Expression> menuDefineExp, Expression> userExp) { var userFunc = userExp; var menuDefineFunc = menuDefineExp; var iqResult = from m in ( (from u in this.UserRepository.GetList(userExp) from r in u.Sys_Role from f in r.Sys_FunctionCode join m in MenuRepository.GetList(menuDefineExp) on f.FunctionCode equals m.FunctionCode select m ).Concat( MenuRepository.GetList(menuDefineExp).Where(x => x.FunctionCode == null) ) ) group m by m into g select g.Key; return iqResult; } } }