Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Filtering

$
0
0

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" ?


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>