score:3
Accepted answer
This assumes your foreign key maps Location.State to Ref_State.ID
Dim LocationList = From rows In db.Locations _
Join rs In Ref_State On rows.State Equals rs.ID _
Order By rows.Address1 _
Select rs.Name
The above answers your original question. After adding the Client table, I would write the query as follows:
Dim LocationList = _
From clientRow In db.Clients _
Join rows in db.Locations On clientRow.ID Equals rows.ClientID _
Join db.stateData In Ref_States On rows.State Equals stateData.ID _
Select ClientName = clientRow.Name, rows.ID, rows.Address1, rows.Address2, rows.City, StateName = stateData.Name, ShortStateName = stateData.ShortName, rows.ZipCode _
Order By Address1
Writing it with the joins explicitly makes it more readable I think.
Source: stackoverflow.com
Related Query
- How can I get my information from the 2 tables into 1 row?
- How can we get an autogenerated Id from the Table While Inserting?
- How can I get the top three players and their high scores from a collection using linq and lambdas
- how can i get the right fields into a group and sum using linq?
- how to get the row value of each column from linq
- How can I get the next appropriate value from a generic list using LINQ?
- How can I use Linq with JSON to get all the Ids from this odd JSON?
- Can someone tell me why this simple bit of c# code won't work, involves recursively calling method from within itself to get the root category ID
- How to get only the max string length column row from a table using linq?
- How to get this linq query to access info from the previous row
- How can I get data from the Entity Framework if I only know the table name and the column name from which to get the data?
- "..cannot be inferred from the usage." How can I insert both a where and an orderby expression into this sqlite query?
- How to convert data from two tables get from Linq query to List witch can be populated in wpf form
- How can i get the manufacturers from all products?
- How to get the max row number from a table by using linq
- How to get NULL from LINQ When no value found in the joining tables
- How to get data from two tables but with where clause on the second (FOREIGN KEY) table? [LINQ]
- How can two left joins from a single table on similar fields be translated into LINQ when more than two tables are involved?
- How can I get the correct values from linq query?
- How can I get the index of an item in a list in a single step?
- How can I get LINQ to return the object which has the max value for a given property?
- How can I get every nth item from a List<T>?
- How can I filter a dictionary using LINQ and return it to a dictionary from the same type
- How do I get the MAX row with a GROUP BY in LINQ query?
- How to get the closest number from a List<int> with LINQ?
- LINQ: How to get items from an inner list into one list?
- How do I get the latest date from a collection of objects using LINQ?
- How to get the count from IQueryable
- How can I get the count in linq?
- How to get the TSQL Query from LINQ DataContext.SubmitChanges()
More Query from same tag
- LINQ implementation of Cartesian Product with pruning
- How to iterate over results of a linq-to-sql query result and append the results?
- Remove duplicates from Dataset but log the removed rows
- Call Expression within a LINQ to Entities with LINQkit
- How to convert string to datetime and then get the lowest date
- How to use parallel linq when two enumerables need to be combined
- Get latest record from a grouping and filter on status
- upload multiple images and display them
- Grabbing most recent transaction/record
- Does converting an IEnumerable to IQueryable enumerate the query
- Multiple Null Foreign keys group join error in Linq
- What is the simplest way to partition a list based on a criteria?
- Linq to return ALL pairs of elements from two lists?
- is there a better way to write this frankenstein LINQ query that searches for values in a child table and orders them by relevance?
- EFcore Joining InMemory Table for duplication of entry
- Restrict EF query to a base type with TPT inheritance
- How to get only date in group by statement in Linq to sql
- How Does Queryable.OfType Work?
- How to collect properties of a list to another list in C#?
- gridview_sorting event using linq to entities c#
- Cached results in Linq Query
- Find in List<t> and return boolean if found
- How to convert from Newton.Json.Linq.JToken to byte[]?
- Linq (GroupBy and Sum) over List<List<string>>
- Windows 10 uwp - Entity Core Sqlite : Include query error
- Faster way to filter a list of objects in to another list based on a condition
- Linq Get history details by year on multiple tables
- LINQ to SQL and compiled queries
- EF: LINQ - orderby using child collection with condition - ArgumentException
- Is this LINQ dynamic orderby method thread safe?