score:3
since you're using linqtosql, you should use datacontext.loadwith when you fetch your objects. this is the preferred way of telling linqtosql what it should pull down (since it defaults to lazy load).
dataloadoptions options = new dataloadoptions();
options.loadwith((employee c) => c.rota);
db.loadoptions = options;
http://msdn.microsoft.com/en-us/library/system.data.linq.dataloadoptions.loadwith.aspx
this has the benefit of being far more efficient on the sql-side when compared with calling tolist or expanding entityref properties individually.
score:0
i assume rota is contained in a collection. set the collection type as list<rota>
, this should work if this is the case.
score:0
you are on the right track already - the query only gets executed once you iterate it (inspecting it in debug mode causes this iteration as well). just call tolist()
on the iqueryable (thus iterating it) before sending it through the web service.
Source: stackoverflow.com
Related Query
- Linq to Sql object not populated
- LINQ SQL query check if a object field is not null
- Linq to sql as object data source - designer problem with partial classes
- convert linq to object query to sql query (no linq to sql code or datacontext)
- DataGridView is not able to populate by LINQ to SQL object
- linq to sql Object Reference not set to an object
- Linq to sql order by a string that is not a property of the object
- Check Nullable for object insde LinQ to Sql code
- nullable object must have a value error in linq to sql in vb.net code
- What can I do to resolve a "Row not found or changed" Exception in LINQ to SQL on a SQL Server Compact Edition Database?
- How are people unit testing code that uses Linq to SQL
- How to add field not mapped to table in Linq to Sql
- LINQ to SQL query not returning correct DateTime
- LINQ to SQL does not update when data has changed in database
- LINQ to SQL in and not in
- LINQ - Returning value of a property of an object that is not null
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- How To Create Generic Data Access Object (DAO) CRUD Methods with LINQ to SQL
- Linq "Could not translate expression... into SQL and could not treat it as a local expression."
- Linq To SQL Attach/Refresh Entity Object
- SQL Query to LINQ syntax using not exist and join
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- c# linq exception: object reference not set to an instance of an object
- Linq to objects when object is null VS Linq to SQL
- LINQ expression is not being translated to SQL
- LINQ Source Code Available
- Operation is not valid due to the current state of the object - Linq on List
- Linq To SQL - Specified cast is not valid - SingleOrDefault()
- Linq to SQL update not working using Repository pattern
- Linq with where clause in many-to-many EF Code First object
More Query from same tag
- Entity framework select with group by
- Help with this Linq query
- Hide Join if string.IsNullOrEmpty using Linq
- Count checked checkboxes in a DataGridView via Linq
- How to write this query using LinQ lambda expression
- Replacing foreach with LINQ query
- Linq to compare two collections in C#
- Using LINQ to convert array object[,] to array
- Calling a Method inside LINQ
- GridView cannot find field in defined type, but anonymous type?
- Delete using LINQ to entityVB.net
- Aggregating lists within objects having the same key
- Parse XML to Tuple
- Linq select item after if statement
- compressing code with C# generics
- How do I fix my linq query
- How does a LINQ expression know that Where() comes before Select()?
- Select statement taking a long time
- LINQ - group specific types of classes
- Store URL Parameter as String Variable ASP.NET
- LINQ query with Inner Join not working when multiple records are added to database
- Write SQL queries using LINQ from linq object List
- Reducing duplicates in a dictionary using LINQ in C#
- LINQ query output groups and subgroups in JSON
- Entity Framework Code First using context in Controller
- Linq xml to object - How to populate a Collection<foo>
- C# Linq Joining queries
- Having problems with inner joins in LINQ
- LINQ query returns way more results than in the entire database
- What's a good "mobile" .NET database that supports LINQ?