Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Reply
The specified LINQ expression contains references to queries
sudesh chhipa
9 years ago
3.5k
Reply
I'm getting error after this join. Normal linq query working fine. I'm using database first approach.
When I'm collecting data from more than one table its throwing exception. The specified LINQ expression contains references to queries that are associated with different contexts.
public partial class EfRepository<T> : IRepository<T> where T : class
{
private readonly WebEntities _context;
private IDbSet<T> _entities;
public EfRepository(WebEntities context)
{
this._context = context;
}
public virtual IQueryable<T> Table
{
get
{
return this.Entities;
}
}
protected virtual IDbSet<T> Entities
{
get
{
if (_entities == null)
_entities = _context.Set<T>();
return _entities;
}
}
}
Query on Service.cs
var query = from rc in _FAQRepository.Table
join r in _FAQCategoryRepository.Table on rc.FAQCategoryID equals r.FAQCategoryID
select rc;
return query.ToList();
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
List of namespace and methods
How to fix Form's Size and design to any screen resolution