但我不知道如何制作where子句。
public class Query
{
public int QueryId { get; set; }
public string QueryName { get; set; }
public string QuerySql { get; set; }
public string CreatedBy { get; set; }
public string QueryType { get; set; }
public string Column1 { get; set; }
public string Operator1 { get; set; }
public string Value1 { get; set; }
public string Connector2 { get; set; }
public string Column2 { get; set; }
public string Operator2 { get; set; }
public string Value2 { get; set; }
public string Connector3 { get; set; }
public string Column3 { get; set; }
public string Operator3 { get; set; }
public string Value3 { get; set; }
public virtual ICollection<Permission> Permissions { get; set; }
}
public class Permission
{
public int PermissionId { get; set; }
public string UserName { get; set; }
}
public IQueryable<Query> GetQueriesForUser(string userName)
{
_context.Queries.Where(m=>m.Permissions.Contains(???))
}
答案 0 :(得分:3)
所以你想要所有的疑问
哪里有该查询的许可
其中,权限的用户名是用户的用户名
您可以使用以下内容:
_context.Queries.Where(q => q.Permissions.Any(p => p.UserName.Equals(userName)));