I have a two related tables.
public partial class Companies
{
public Companies()
{
ContactsNavigation = new HashSet<Contacts>();
}
public int Id { get; set; }
public string Inn { get; set; }
public string MainName { get; set; }
public string Name { get; set; }
public string Place { get; set; }
public string Contacts { get; set; }
public string Notes { get; set; }
public int Rate { get; set; }
public string Comments { get; set; }
public string Responsible { get; set; }
public bool? Favorites { get; set; }
public ICollection<Contacts> ContactsNavigation { get; set; }
}and
public partial class Contacts
{
public int Id { get; set; }
public string NameFio { get; set; }
public string PhoneNumber { get; set; }
public string Mail { get; set; }
public string Username { get; set; }
public int? IdofMedInst { get; set; }
public int? IdofCompanies { get; set; }
public string Position { get; set; }
public Companies IdofCompaniesNavigation { get; set; }
}Than I create "CompaniesController" with filtering
IQueryable<Companies> Company = _context.Companies.Include(c => c.ContactsNavigation);
if (!String.IsNullOrEmpty(CompaniesInput))
{
Company = Company.AsQueryable().Where(p => p.Inn.Contains(CompaniesInput) ||
p.Name.Contains(CompaniesInput) || p.Contacts.Contains(CompaniesInput));
}Is there any way to find all Companies where Contacts (from table Contacts) contain data from "CompaniesInput" ?