【发布时间】:2017-08-27 04:16:36
【问题描述】:
我有以下代码优先实体 -
public class Contact
{
public Contact()
{
this.Tags = new HashSet<Tag>();
}
public int ContactId { get; set; }
public string ContactName { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
public class Tag
{
public Tag()
{
this.Contacts = new HashSet<Contact>();
}
public int TagId { get; set; }
public string TagName { get; set; }
public virtual ICollection<Contact> Contacts { get; set; }
}
我想根据字符串数组中的标签属性搜索联系人。类似于以下内容-
//string[] tags
Select from Db.Contacts where any Tag matched with any item in arrTags
我无法弄清楚它是如何在 lambda 中完成的。有什么帮助吗?
【问题讨论】:
标签: c# lambda icollection