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 Articles
- LINQ Source Code Available
- Linq with where clause in many-to-many EF Code First object
- creating Linq to sqlite dbml from DbLinq source code
- Linq to sql as object data source - designer problem with partial classes
- Convert this LINQ code back to a Loop (or Why is this object sometimes null)
- convert linq to object query to sql query (no linq to sql code or datacontext)
- Linq to Sql object not populated
- source code for LINQ 101 samples
- C#: Get object from Combobox populated with Linq
- Linq code to get the index of an object in an array from an object within a list
- Create a tree structure in linq with a single list source with parent - child as strings of an object
- Check Nullable for object insde LinQ to Sql code
- c# Linq or code to extract groups from a single list of source data
- nullable object must have a value error in linq to sql in vb.net code
- How to use LINQ to select object with minimum or maximum property value
- Deserializing JSON to .NET object using Newtonsoft (or LINQ to JSON maybe?)
- Convert string[] to int[] in one line of code using LINQ
- LINQ Group By into a Dictionary Object
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- How can I get LINQ to return the object which has the max value for a given property?
- Create a list from two object lists with linq
- Linq code to select one item
- How to get first object out from List<Object> using Linq
- Return list of specific property of object using linq
- How are people unit testing code that uses Linq to SQL
- LINQ selection by type of an object
- LINQ - Does the Where expression return new instance or reference to object instance
- LINQ to SQL: GroupBy() and Max() to get the object with latest date
- Linq select to new object
- Iterate through properties and values of an object returned via a linq query on a domain model
- How to pass value by reference in C#?
- Limit number of items returned by Linq GroupBy
- Searching a List of List
- How to LINQ Query Code First generated EF6 hierarchical entities (entities within entities)?
- query a class object using linq
- How to run single process for multiple values in c#?
- Cast an object to an array of string?
- LINQ to Entities OrderBy Expression Tree
- Mapping values of grouped query?
- Using linq to query SQL Server is causing 100s of small queries
- C# List of different object types: Better way than Zip to check equality
- Finding overlapping and gaps between two numbers in a list
- Linq join with newest record of second table
- How can I get the average of two different columns in linq?
- Linq to XML: Get all nodes that contain certain children
- Create Combinations according to the position in c# list
- Viewing data from another model results in DynamicProxies object being shown
- sort list by custom filter of string.contains
- Cannot make 5 consecutive "joins" in LINQ?
- Question About Querying Linq Results