c# - Multiple cross reference table joins in linq -


It's been annoying me for a while because I'm trying to come in an optimized way to find it.

So you can say that I have 3 cross reference tables, which share a common column, where common columns will include one last in a main table with more information. For example:

Say: I have the following:

  Customers / Properties: ID, name, address, IEnumberable < Customer Support & gt; // Properties: Customer ID, Sports ID INMbell & lt; Customer Location & gt; // Properties: Customer ID, Location ID IEnumberable & lt; Customers & gt; // Properties: Customer ID, Pete's ID  

So I can make a question like this:

I have clients of lacrosse, football, soccer (customer support) List two. .. and dogs and cats (customerspets) who live in New York (customer location). Lookup tables can be faucetable, so customers can play games, but there is no pet.

Then when I get a list of customers, I will find that customer ID in the common column (customer ID), ID, name and address.

I was thinking about joining the customer table every, and then was bringing a union to bring the list of customers, but I do not know it's the right way to do this.

Unless you have correctly organized your design, each customer game collection, a pet collection and a location (unless it is included in the last one-to-one

If those relationships are setup, then you can query as follows:

  var sports = new string [] {"lacrosse", " Football "," football "}; var pet = new string [] {" cat "," dog "}; var Than = new String [] { "New York"}; Var sportyPetLoversInNewYors = db.Customers. Where (cust = & gt; Kelksbi (game = & gt; cust.Sports.Any (custSport = & gt; custSport.Name == game))). (Customer => Pets. All (pet = & gt; cust.Pets.Any (custPet = & gt; custPet.Name == Pets)). (Where customer = & All of the place (लोक = & gt; cust.Locations.Any (custLoc = & gt; custLoc .Name = loc))) // sub-lists or whatever can be customized here to include selection. Choose ();  

It assumes that you want only those people who have 6 criteria, if you want at least one of those games, at least among those pets One, and (you handle the use of multiple locations) are in at least one location, then will change like where expression

 . Where (customer = & gt; cust.port.Any (custSport = & gt; game.Content (custSport.Name)))  

Tell me that you need more clarification.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -