0
我在写一个简单的联系人管理应用程序。在我的域名模式中,我有很多联系人和标签之间的关系。现在在我的mvc中,我需要询问用户选择的标签并返回所有具有与用户提供的标签相匹配的标签的联系人。查询使用给定标签过滤联系人,同时在实体之间具有多对多关系
例如,如果联系najam有3个标签 - “author”,“blogger”,“subscriber”和管理员选择“author”和“subscriber”进行搜索,那么应该在搜索结果中找到najam。
public class Tag {
public Tag()
{
CreatedOn = DateTime.Now;
}
public int TagID { get; set; }
public string Name { get; set; }
public DateTime CreatedOn { get; set; }
public virtual ICollection<Contact> Contacts { get; set; }
}
public class Contact
{
public Contact()
{
isNewsletterSubscriber = true;
CreatedOn = DateTime.Now;
}
public int ContactID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Organization { get; set; }
public string CellPhone { get; set; }
public string Designation { get; set; }
public string Address { get; set; }
public string PhoneNumber { get; set; }
public bool isNewsletterSubscriber { get; set; }
public string Twitter { get; set; }
public string Facebook { get; set; }
public DateTime CreatedOn { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
我一直在玩LinqPad linq表达式,但无法找出解决方案。我试过在where子句中使用contains和ant。
告诉我们你用linq表达式试过了什么,但没有成功。 – Silvermind 2014-10-27 18:16:21