score:3
Accepted answer
Something like this?
var query =
from p in ctx.Problem
join pf in ctx.ProblemFactory on p.ProblemFactoryID equals pf.ProblemFactoryID
join pt in ctx.ProblemType on pf.ProblemTypeID equals pt.ProblemTypeID
join o in ctx.Objective on pf.ObjectiveID equals o.ObjectiveID
select new
{
p.ProblemID,
pf.ObjectiveID,
o.Name,
pf.Time,
pt.ProblemTypeName,
pf.OperationID,
pf.Range1ID,
pf.Range2ID,
pf.Range3ID,
pf.Range4ID,
pf.MissingNumber,
};
But what do you mean by the "SQL Select properties"?
score:0
One of the benefits of an ORM like Linq-to-SQL is that we don't have to flatten our data to retrieve it from the database. If you map your objects in the designer (i.e. if you have their relationships mapped), you should be able to retrieve just the Problems
and then get their associated properties as required...
var problems = from problem in dc.Problem2s select problem;
foreach (var problem in problems)
{
// you can work with the problem, its objective, and its problem type.
problem.DoThings();
var objective = problem.Objective;
var type = problem.ProblemType;
}
Thus you retain a logical data structure in your data layer, rather than anonymous types that can't easily be passed around.
Source: stackoverflow.com
Related Query
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- How do I convert this SQL query to LINQ to SQL
- How to convert this SQL query to LINQ or Lambda expression?
- How do i convert this linq code to inline sql
- How to convert this complex SQL Query with Subqueries into LINQ
- Convert this SQL Query to LINQ Query
- convert linq to object query to sql query (no linq to sql code or datacontext)
- How to convert this String-based sql query to use Linq
- How to convert SQL to linq for this query
- Convert this SQL query to LINQ using .GroupBy() methods
- Convert this SQL query to LINQ to SQL
- How can I convert this SQL query to LINQ
- Need to Convert this SQL query to LINQ
- How to convert this SQL query to Linq
- Can anyone convert this SQL query into a C# Linq statement?
- Convert this SQL query into Linq
- How do I convert this SQL inner join query into LINQ syntax?
- Convert this SQL query to Linq (Not Exists + sub query)
- How to convert this SQL query to LINQ or Lambda expression in C#?
- How to convert this query from SQL to LINQ
- Convert this SQL Query to a Linq Lambda Expression
- Convert SQL update query to c# LINQ code
- How to convert this sql query into linq query. I am stuck at the group by and sum part
- How to convert this query string into LINQ to SQL query?
- How to convert this Sql query to LINQ query
- How to convert this SQL query to Linq to Entity query?
- Help me convert this SQL query to LINQ
- How can I convert this query from SQL to linq
- I want to convert this SQL query to linq using C#
- How to convert this SQL Query to LINQ Query?
More Query from same tag
- Using linq to find the cheapest item in a list thats greater than 0
- How can I filter rows where the first character of a column is in a range with EF and SQL Server?
- How to OrderBy nested Object value Linq
- The variable SI of type Microsoft.Xrm.Sdk.Entity is refenced on this scope, but it is not defined
- How to write a word after 50 lines in text file
- Using Linq to query repository returning invalid results
- Does LINQ Select affect on performance?
- WCF Data Service Operation cast issue
- Conditional where with or criteria linqtosql
- Using reflection to retrieve a value from a list
- Select concat between colections by linq
- Sorting in C# using linq
- Linq 2 Sybase ASE database? What are the options?
- The type '<>f__AnonymousType2`2[System.String,System.Int32]' must declare a default (parameterless) constructor
- strange behavior in linq to sql
- C# LINQ - Group List by a property then select by different groups
- Linq left join with multiple tables
- Where IN clause in LINQ
- IQueryable to List
- LINQ - Get Max Value of a group of elements
- Returning the wrong type - cast?
- More Efficient LINQ Query
- How to retrieve a substring based on a first list match
- Linq GroupBy - how to specify the grouping key at runtime?
- DataGridView - Fill DataSet with Linq
- Querying an IQuery from a cached list returns null exception
- String replace all sub string found matching the list of strings C# LINQ
- Does PLINQ really not preserve order?
- distinct set operator in linq
- string linq to entities error - json