public static System.Data.DataTable getDataByRight <T>(DbContext dbContext, SqlAdvancedSelect sqlAdvancedSelect, Guid userId, T Tobj, bool isRigth) where T : MyEntityBase { sqlAdvancedSelect.mainTable = Tobj.getTableName(); if (string.IsNullOrEmpty(sqlAdvancedSelect.orderStr)) { sqlAdvancedSelect.orderStr = $"[{Tobj.getTableName()}].[{Tobj.getIdName()}]"; } // if (sqlAdvancedSelect.fields == null || sqlAdvancedSelect.fields.Count == 0) // { // sqlAdvancedSelect.fields = new List<string>(); // sqlAdvancedSelect.fields.Add("*"); // } if (string.IsNullOrEmpty(sqlAdvancedSelect.whereStr)) { sqlAdvancedSelect.whereStr = "1=1"; } var whereRight = isRigth ? RightHelper.getReadWhereSql(userId, sqlAdvancedSelect.mainTable) : "1=1"; var sql = sqlAdvancedSelect.getSql(whereRight); var result = dbContext.Database.SqlQueryDataTableCheckKey(sql); return(result); }
private void Initi(string wechatUserId) { DataTable dt = RightHelper.GetUserRights(wechatUserId); if (dt == null || dt.Rows.Count == 0) { return; } dict = new Dictionary <string, List <Menu> >(); foreach (DataRow row in dt.Rows) { string key = row["typeName"].ToString(); Menu menu = new Menu(row["pageName"].ToString(), row["webSite"].ToString()); if (dict.Keys.Contains(key)) { bool hasContained = false; foreach (Menu m in dict[key]) { if (m.Name == menu.Name) { hasContained = true; break; } } if (!hasContained) { dict[key].Add(menu); } } else { List <Menu> list = new List <Menu>(); list.Add(menu); dict.Add(key, list); } } }