LINQ "include" missing. after reading this post: http://romiller.com/2010/07/14/ef-ctp4-tips-tricks-include-with-lambda/
i would like to use include. this is my class:
public class Service
{
#region Properties
/// <summary>
/// Gets or sets CatalogRootNodeId.
/// </summary>
public virt开发者_如何学JAVAual int CatalogRootNodeId { get; set; }
/// <summary>
/// Gets or sets ServiceDomain.
/// </summary>
public virtual ICollection<ServiceDomain> ServiceDomain { get; set; }
#endregion
}
I would like to "Include" all ServiceDomains but "Include" option is not there ?? I'm working with MVC3 and EF. thanks
Are you using CTP5 or CTP4? If you do, you can use the extension method from System.Data.Entity.DbExtensions.Include.
public static IQueryable<T> Include<T>(this IQueryable<T> source, Expression<Func<T, object>> path)
var db = new MyDbContext();
var services = db.Services.Where(s => s.CatalogRootNodeId == 1).Include(s => s.ServiceDomain);
You need to call Include()
on the ObjectSet<Service>
from the DataContext
.
精彩评论