score:1
Accepted answer
public static list<category> getcategorylist()
{
try
{
using (var db = new linqtodbawkodatacontext())
{
var list = from c in db.tblcategories
join s in db.tblsubcategories
select new category
{
id = c.catid,
catname = c.catname,
subcat = s.subcatname
};
return list.tolist();
}
}
catch (exception ex)
{
throw new exception("an error has occured");
}
}
Source: stackoverflow.com
Related Query
- select from multiple tables with linq to sql
- Select data from multiple unrelated tables with LINQ to Entity Framework
- How to select data from multiple tables with LINQ (entities)
- Select Distinct from multiple tables linq to sql
- Select data from 3 tables with Linq to SQL
- Creating a LINQ select from multiple tables
- LINQ to SQL: Complicated query with aggregate data for a report from multiple tables for an ordering system
- LINQ to SQL join 3 tables and select multiple columns and also using Sum
- How to select multiple columns from dataset into a string list with LinQ
- Populate a C# class from a dataset with multiple linked tables using linq lambda
- Pull data from multiple tables in one SQL query using LINQ and Entity Framework (Core)
- Using LINQ to select all from multiple tables
- Linq to SQl, select same column from multiple tables
- LINQ to SQL select distinct from multiple colums
- Linq to sql - Join 2 tables, select 1 row from right table with a 1 to many relationship
- How to write SQL SELECT INNER JOIN with multiple conditions (with LIKE) query to LINQ to SQL
- Converting SQL to LINQ with Multiple Tables and Group
- Retrieving Data From Multiple Tables in a LINQ to SQL query
- Select multiple table with Linq to Sql
- LINQ to SQL join two tables to select parent table twice based on two different columns from child table
- Get the max date from linq with mutiple joins and with multiple select fields
- How to get entities from multiple tables with one LINQ call?
- Linq to select same datatype from multiple tables
- AP.NET webforms using LINQ to SQL datasource and databind with foreign keys across multiple tables
- C# Linq Select data from multiple tables
- write linq similiar where in select from with inner join in sql query
- LINQ Select with multiple tables fields being writeable
- Group Joins with multiple tables converting SQL to Linq
- Select values from multiple dictionaries into list of objects with LINQ
- Select multiple columns with linq to sql
More Query from same tag
- joining two linq results which is not of same type using linq
- How to get name data of multiple json object list that will be posted to web api?
- nhibernate queryover with complex join over non-related entities
- Is there a way to remove extra newlines from text using LINQ?
- Error on System.Linq.Enumerable.<TakeIterator>d__3a`1.MoveNext()
- Adding Selected Properties to List and return as API Call in C#
- LINQ to SQL: making a "double IN" query crashes
- Avoiding SingleOrDefault null reference exception
- Search from the string array and ignore that exact matched string
- Linq Join query returning empty dataset
- Search two lists for at least one match with LINQ
- LINQ / Multiple GroupBy. Which is the proper one, recursive usage or chain usage?
- LINQ GroupBy with a dynamic group of columns
- How do I transform a database table into a "pivot" DataTable?
- Bind WPF DataGrid to LINQ Query (Entity Framework)
- Moq First() Last() and GetEnumerator() wierdness
- Select new object as a parameter while preserving it's run-time-generated type
- Linq Includes Alternative
- removing fields with numbers in linq to entity query
- Changing a linq query to filter on many-many
- Why does Resharper suggest a code change and then complain about the change?
- Determine if collection is of type IEnumerable<T>
- Reflection order by property
- Instantiating Immutable Objects With Reflection
- Visual Basic LINQ
- Retrieving specific elements from an XDocument based on a list
- How to create a Dictionary out of two separate lists using linq and lambda expressions
- LINQ select: want to pass collection into CONTAINS
- How do I return the ancestors of an object with LINQ?
- Using List.Find or LINQ on lists of enums in .NET 3.5