如何在查询中包含 ()
How to include () in query
iam 有两个模态我试图包括属于用户的所有 Post。但是,我不断收到以下调试错误:
错误 58 无法将 lambda 表达式转换为类型 'string' 因为它不是委托类型
请看图
public IList<User> GetSliderImages()
{
var q = db.Users.Include(x=>x.Post).OrderByDescending(x => x.FPersonalUser).Where(x => x.typemanger == 1).ToList();
return q;
}
public class User
{
[Key]
public int ID_User { set; get; }
public Int16 ID_post { set; get; }
public bool Fbofd { set; get; }
public string FuserName { set; get; }
public bool Foffice { set; get; }
public byte[] FPicaddress { set; get; }
**public IList<Post> _post { set; get; }**
}
public partial class Post
{
[Key]
public int ID_Post { set; get; }
public string FNamePost { set; get; }
}
public virtual ICollection<Post> Post{ get; set; }
请像这样使用两个 table 之间的关系,然后使用 include 语法。
iam 有两个模态我试图包括属于用户的所有 Post。但是,我不断收到以下调试错误: 错误 58 无法将 lambda 表达式转换为类型 'string' 因为它不是委托类型
请看图
public IList<User> GetSliderImages()
{
var q = db.Users.Include(x=>x.Post).OrderByDescending(x => x.FPersonalUser).Where(x => x.typemanger == 1).ToList();
return q;
}
public class User
{
[Key]
public int ID_User { set; get; }
public Int16 ID_post { set; get; }
public bool Fbofd { set; get; }
public string FuserName { set; get; }
public bool Foffice { set; get; }
public byte[] FPicaddress { set; get; }
**public IList<Post> _post { set; get; }**
}
public partial class Post
{
[Key]
public int ID_Post { set; get; }
public string FNamePost { set; get; }
}
public virtual ICollection<Post> Post{ get; set; }
请像这样使用两个 table 之间的关系,然后使用 include 语法。