简体   繁体   中英

Is it possible to include a list in a DbSet?

WCF Service Demo Code

public List<Message> GetMessages(string userAddress)
{
    return this.projectContext.Messages.Include("Contacts").ToList();
}

Message Class

public class Message
{
    public int Id { get; set; }
    public string Text { get; set; }
    public List<Contact> Contacts { get; set; }
}

When i try to consume that method on client side i get the next error:

在此处输入图片说明

如果您将联系人设为实体,则可以在上下文中包含联系人实体,并通过外键将其映射到消息实体。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM