Note that there are some explanatory texts on larger screens.

plurals
  1. POsimple linq to sql has no supported translation to SQL
    text
    copied!<p>i have this in my BlogRepository</p> <pre><code>public IQueryable&lt;Subnus.MVC.Data.Model.Post&gt; GetPosts() { var query = from p in db.Posts let categories = GetCategoriesByPostId(p.PostId) let comments = GetCommentsByPostId(p.PostId) select new Subnus.MVC.Data.Model.Post { Categories = new LazyList&lt;Category&gt;(categories), Comments = new LazyList&lt;Comment&gt;(comments), PostId = p.PostId, Slug = p.Slug, Title = p.Title, CreatedBy = p.CreatedBy, CreatedOn = p.CreatedOn, Body = p.Body }; return query; } </code></pre> <p>and </p> <pre><code>public IQueryable&lt;Subnus.MVC.Data.Model.Comment&gt; GetCommentsByPostId(int postId) { var query = from c in db.Comments where c.PostId == postId select new Subnus.MVC.Data.Model.Comment { Body = c.Body, EMail = c.EMail, Date = c.CreatedOn, WebSite = c.Website, Name = c.Name }; return query; } private IQueryable&lt;Subnus.MVC.Data.Model.Category&gt; GetCategoriesByPostId(int postId) { var query = from c in db.Categories join pcm in db.Post_Category_Maps on c.CategoryId equals pcm.CategoryId where pcm.PostId == postId select new Subnus.MVC.Data.Model.Category { CategoryId = c.CategoryId, Name = c.Name }; return query; } </code></pre> <p>and when i aplly this filter </p> <pre><code>namespace Subnus.MVC.Data { public static class BlogFilters { public static IQueryable&lt;Post&gt; WherePublicIs(this IQueryable&lt;Post&gt; qry,bool state) { return from p in qry where p.IsPublic == state select p; } } </code></pre> <p>}</p> <p>all this is in the same namespace if that help namespace Subnus.MVC.Data</p> <p>when i try to do this </p> <pre><code>public class BlogService : IBlogService { ... public IList&lt;Post&gt; GetPublicPosts() { return repository.GetPosts().WherePublicIs(true).ToList(); } ... } </code></pre> <p>that is in the namespace Subnus.MVC.Service it throws the error </p> <pre><code>Method 'System.Linq.IQueryable`1[Subnus.MVC.Data.Model.Comment] GetCommentsByPostId(Int32)' has no supported translation to SQL. </code></pre>
 

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