Note that there are some explanatory texts on larger screens.

plurals
  1. POInclude is gone
    primarykey
    data
    text
    <p>I am trying to replace the joins and use include but I don't know how to do that:</p> <pre><code> IRepository&lt;Call&gt; callRepository = ObjectFactory.GetInstance&lt;IRepository&lt;Call&gt;&gt;(); IRepository&lt;Reason&gt; reasonRepository = ObjectFactory.GetInstance&lt;IRepository&lt;Reason&gt;&gt;(); IRepository&lt;SimTask.Domain.Business.Entities.System.Company&gt; companyRepository = ObjectFactory.GetInstance&lt;IRepository&lt;SimTask.Domain. Business.Entities.System.Company&gt;&gt;(); IQueryable&lt;CallsListItem&gt; x = from call in callRepository.GetQuery() join reason in reasonRepository.GetQuery() on call.ReasonId equals reason.Id join company in companyRepository.GetQuery() on call.CompanyId equals company.CompanyId where call.CompanyId == companyId &amp;&amp; (!isClosed.HasValue || call.IsClosed.Equals(isClosed.Value)) select new CallsListItem() { CallId = call.Id, Description = call.Description, CloseDateTime = call.CloseDateTime, IsClosed = call.IsClosed, OpenDateTime = call.OpenDateTime, PhoneNumber = call.PhoneNumber, ReasonName = reason.Name, CompanyName = company.CompanyName }; </code></pre> <p>IRepository is implemented by:</p> <pre><code>public class EFRepository&lt;T&gt; : IRepository&lt;T&gt; where T : class { ObjectContext _context; IObjectSet&lt;T&gt; _objectSet; private ObjectContext Context { get { if (_context == null) { _context = GetCurrentUnitOfWork&lt;EFUnitOfWork&gt;().Context; } return _context; } } private IObjectSet&lt;T&gt; ObjectSet { get { if (_objectSet == null) { _objectSet = this.Context.CreateObjectSet&lt;T&gt;(); } return _objectSet; } } public TUnitOfWork GetCurrentUnitOfWork&lt;TUnitOfWork&gt;() where TUnitOfWork : IUnitOfWork { return (TUnitOfWork)UnitOfWork.Current; } public IQueryable&lt;T&gt; GetQuery() { return ObjectSet; } public IEnumerable&lt;T&gt; GetAll() { return GetQuery().ToList(); } public IEnumerable&lt;T&gt; Find(Func&lt;T,bool&gt; where) { return this.ObjectSet.Where&lt;T&gt;(where); } public T Single(Func&lt;T,bool&gt; where) { return this.ObjectSet.Single&lt;T&gt;(where); } public T First(Func&lt;T,bool&gt; where) { return this.ObjectSet.First&lt;T&gt;(where); } public void Delete(T entity) { this.ObjectSet.DeleteObject(entity); } public void Add(T entity) { this.ObjectSet.AddObject(entity); } public void Attach(T entity) { this.ObjectSet.Attach(entity); } public void SaveChanges() { this.Context.SaveChanges(); } } </code></pre> <p>Why is Include better then joins?<br> How can I do Include?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload