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 Articles
- How can I get my information from the 2 tables into 1 row?
- Linq: select from multiple tables into one pre-defined entity
- creating Linq to sqlite dbml from DbLinq source code
- Gettings grouped sums from related tables into linq query columns
- Linq result from many tables into an inherit class with nested classes
- What's the best way to copy and insert data from related tables into a new set of related tables with Linq
- Can't add a new record with an integer value into database by using linq from code C#
- Join data from multiple tables into SelectList, and precede each dataset with a caption in MVC
- Linq to Entites 6, Many-to-many relationship, Selecting Fields from Both tables into an object
- How to return IQueryable LINQ result from two joined tables into a List<string>?
- Select * from two tables into two separate lists
- IQueryable two tables from Code First Entity Framework
- I want to retrieve data from multiple tables to service payer into my project
- How to use Linq to select information from a collection into another concrete class I made?
- c# Linq or code to extract groups from a single list of source data
- Using LINQ, join data from tables into single rows in multi list form view
- Moving code from the view into the LINQ query
- LINQ: Query to get information from 2 tables
- How can two left joins from a single table on similar fields be translated into LINQ when more than two tables are involved?
- Getting information from two tables that are in relation
- Merging data from two tables into one view
- getting data from unbinded view and submitting form data with linq into tables
- Query to get information from multiple tables
- Creating a LINQ select from multiple tables
- LINQ: How to get items from an inner list into one list?
- Nullable reference type information not exposed from FirstOrDefault
- Linq. Select from multiple tables
- Split datatable into multiple fixed sized tables
- How to inner join tables from different Data Context?
- Joining tables from two databases using entity framework
- Linq2DB adding unnecessary statements to query
- I can dynamically create an Expression<Func<T, bool>> predicate ,but how do i create Expression<Func<T1,T2,bool>>
- EntityFramework : Calling ToList() on IQueryable with ~11.000 records takes 10 seconds
- Linq request with BETWEEN
- Calling generic method with a type argument known only at execution time
- EF related entities not showing when empty
- Insert expression into LINQ statement for Linq-To-Sql
- Easy way to convert Datatable to List using C#
- Visual Studio .Net source stepping for System.Linq
- Can someone please explain this lazy evaluation code?
- directory.getfiles stops searching when error
- Pick element from xml
- Linq - Project List<A> to grouped List<B> with a C object within List<B>
- NHibernate 3 and LINQ support?
- display url slug instead of id in mvc
- Find the indexes of change points in sequences of contiguous numbers using Linq
- Convert SqlDataReader to linq expression
- Date Format in C# Linq
- How to get xml log elements by searching the specific string/text using LINQ
- Encrypt column data with LINQ