如何在查询中包含()

时间:2015-02-24 06:59:06

标签: asp.net-mvc linq-to-entities

我有两种模式我想尝试包含属于用户的所有 发布 。但是,我不断收到以下调试错误: 错误58无法将lambda表达式转换为类型'string',因为它不是委托类型

请参见图片enter image description here enter image description here

 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; }

}

1 个答案:

答案 0 :(得分:-1)

public virtual ICollection<Post> Post{ get; set; } 

请使用这样看两个表之间的关系,然后使用include语法。