score:1
Accepted answer
ilist<ticketlistmodel> ticketlist = (from t in db.tickets
join e in db.employees on t.id equals e.id
select new ticketlistmodel
{
number = t.number,
requestdate = t.requestdate,
applicant = e.name,
comname = comlibs.name,
probtype = t.probtype,
probdetail = t.probdetail,
status = t.status
}).tolist();
score:0
public actionresult index()
{
ilist<ticketlistmodel> ticketlist = new list<ticketlistmodel>();
var ticketlistquery = from t in db.tickets
from a in db.employees
where t.id == a.id
select new ticketlistmodel
{
t.number,
t.requestdate,
applicant = a.name,
comname = comlibs.name,
t.probtype,
t.probdetail,
t.status
};
ticketlist = ticketlistquery.tolist();
return view(ticketlist);
}
score:0
public actionresult index()
{
ilist<ticketlistmodel> ticketlist = new list<ticketlistmodel>();
var ticketlistquery = from t in db.tickets
select new ticketlistmodel
{
number = t.number,
requestdate = t.requestdate,
applicant = t.applicant.name,
comname = t.comlib.name,
probtype = t.probtype,
probdetail = t.probdetail,
status = t.status
};
ticketlist = ticketlistquery.tolist();
return view(ticketlist);
}
Source: stackoverflow.com
Related Query
- Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator
- LINQ to SQL query using "NOT IN"
- how to see generated sql from a linq query
- How to write linq query to match SQL like select top 100 * from tab?
- How do I most elegantly express left join with aggregate SQL as LINQ query
- LINQ To SQL exception: Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains operator
- Steps for a beginner to run very basic linq to sql query using Linqpad
- linq to sql recursive query
- Extract sql query from LINQ expressions
- Convert SQL to LINQ Query
- LINQ to SQL query not returning correct DateTime
- Calling a SQL User-defined function in a LINQ query
- How to force LINQ to SQL to evaluate the whole query in the database?
- Optimize LINQ query that runs fast in Sql server?
- linq to sql query with multiple where parameters
- Simple sql to Linq query with group by and aggregate functions
- How to intercept and modify SQL query in Linq to SQL
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- SQL Query to LINQ syntax using not exist and join
- Dynamic query using LINQ to SQL
- Linq to SQL - How to sort results from query
- Where to find translated Linq to Entity query to Sql
- Dynamic linq query expression tree for sql IN clause using Entity framework
- LINQ SQL query check if a object field is not null
- Rewriting a LINQ Expression query to enable caching SQL Execution Plan
- SUM and COUNT in single LINQ to SQL query
- Check LINQ query against SQL Server database
- Convert SQL query to LINQ
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- Dynamically construct "or" LIKE query in LINQ to SQL
More Query from same tag
- Nullable int not working as expected in LINQ (C#)
- How to sort C# Datatable with empty column values at the end
- Placing values from a joint table in a class in C#
- How to get difference sum of between keys in a Dictionary object C#
- Why am I unable to do a count after a GroupBy with LINQ
- Using LINQ to get a string from a tab delimited text file into an array in the way I want
- How can I optmize a "select all" statement in linq that casts ~4000 rows to objects?
- LINQ to SQL join 3 tables and select multiple columns and also using Sum
- How to obtain an enumerable over the lines of standard input in C#?
- Simple Linq to Xml Queries setting Properties with Elements (instead of IEnumerable)
- Return the number of times a string occurs as a property in a list of custom objects
- How to use partition by in Linq query in C#, to add column values in subsequent rows?
- what is the best linq query for this
- ASP.NET - Entity Framework - Only parameterless constructors and initializers are supported in LINQ to Entities
- How do I use CURRENT_TIMESTAMP in a LINQ update statement using Entity Framework Core?
- (MVC C#)Advice on my Maintenance Scheduling system with Maintenance Records
- Entityframe Linq using Max and Min
- Search on array of multiple type objects
- How can I return variable column lengths via LINQ to SQL
- join two collections on a custom condition
- Getting unique objects using LINQ
- C# LINQ to SQL Invalid Object Name
- LINQ SingleOrDefault, Brush, what I am doing wrong?
- Is possible to convert linq lambda expressions to SQL using dart?
- How to make a natural-looking list?
- How to extend this LINQ List<>.Contains to work with any Property using Reflection?
- using Single/First methods to return multiple values in linq or lambda expression
- How can get a result of a linq stored procedure into a label which is scalar
- why null values not return in when apply != in linq
- Apply a custom method on EntityFramework results