<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data Access and ObjectDataSource Control</title><link>http://forums.asp.net/23.aspx</link><description>Questions and discussions related to using ADO.NET for data access, and the ObjectDataSource control. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=9&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: LINQ Issue: no supported translation to SQL</title><link>http://forums.asp.net/thread/2468168.aspx</link><pubDate>Fri, 04 Jul 2008 19:34:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2468168</guid><dc:creator>chris.wall</dc:creator><author>chris.wall</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2468168.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=2468168</wfw:commentRss><description>&lt;p&gt;Well, changing&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;chris.wall:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/p&gt;&amp;lt;code&amp;gt;&lt;br /&gt;&lt;pre&gt;///This is the method in my Linq to SQL Repository&lt;br /&gt;public IQueryable GetNewsPosts()&lt;br /&gt;{&lt;br /&gt;    return from n in _context.NewsPosts&lt;br /&gt;           select new Business.NewsPost(n);&lt;br /&gt;}&lt;/pre&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;/code&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;To be&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;lt;code&amp;gt; &lt;/p&gt;&lt;pre&gt;    return from n in _context.NewsPosts&lt;br /&gt;           select new Business.NewsPost&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre&gt;ID = n.ID,&lt;/pre&gt;&lt;pre&gt;Title = n.Title,&lt;/pre&gt;&lt;pre&gt;Body = n.Body&lt;/pre&gt;&lt;pre&gt;};&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;lt;/code&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;It all works as expected now, I&amp;#39;m just not sure why it wouldn&amp;#39;t work by passing &amp;quot;n&amp;quot; into the business object&amp;#39;s constructor.  Any ideas?  at least I found a way to get it working.. &lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>LINQ Issue: no supported translation to SQL</title><link>http://forums.asp.net/thread/2466575.aspx</link><pubDate>Fri, 04 Jul 2008 02:45:47 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2466575</guid><dc:creator>chris.wall</dc:creator><author>chris.wall</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2466575.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=2466575</wfw:commentRss><description>&lt;p&gt;I apologize in advance if this is the wrong forum to post this in, didn&amp;#39;t see any forum&amp;#39;s description mentioning LINQ.&lt;/p&gt;

&lt;p&gt;I am getting the following exception:&lt;/p&gt;

&lt;p&gt;The member &amp;#39;[MyBusinessClass].ID&amp;#39; has no supported translation to SQL.&lt;/p&gt;

&lt;p&gt;For starters, this isn&amp;#39;t even a Linq to Sql class. Am I wrong to assume that I can plug an object into an IQueryable collection and query it as I would a database?&lt;/p&gt;

&lt;p&gt;Edit: When I try the following line of code everything works fine&lt;br /&gt;
&lt;code&gt;
this._repository.GetNewsPosts().ToList().AsQueryable().WithID(someGuid);
&lt;/code&gt;
&lt;br /&gt;
But this still does not:&lt;br /&gt;
&lt;code&gt;
this._repository.GetNewsPosts().WithID(someGuid);
&lt;/code&gt;
&lt;br /&gt;
See below for the meat of the GetNewsPosts and WithID methods.
&lt;/p&gt;
&lt;p&gt;The whole of what is happening makes it more odd.&amp;nbsp; I am running some unit tests on a website I am working on.&amp;nbsp; I wanted to do it all in LINQ to learn the new language features in 3.5.&amp;nbsp; I have a Service class and a Repository class.&amp;nbsp; The service has convenience methods like GetItemsById(guid id) which maps to a call to repository that gets an IQueryable of business objects (NOT the objects in my dbml file, but a translation of one of those) using an extension method (WithId(this IQueryable&amp;lt;BizObj&amp;gt; objects, guid id))&amp;nbsp; It&amp;#39;s all set up with interfaces (IService and IRepository) for my IoC container. When I unit test the Service using a mock repository everything works fine.&amp;nbsp; When I unit test the actual repository the WithID method throws an exception.&amp;nbsp; Here are some snippets of the code I am working with:&lt;/p&gt;
&lt;code&gt;&lt;/code&gt;
&lt;pre&gt;///This is the extension method&lt;br /&gt;public static IQueryable WithID(this IQueryable businessObjects, Guid postID)&lt;br /&gt;{&lt;br /&gt;    return from n in businessObjects&lt;br /&gt;           where n.ID == postID&lt;br /&gt;           select n;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///This is the method in my Linq to SQL Repository&lt;br /&gt;public IQueryable GetNewsPosts()&lt;br /&gt;{&lt;br /&gt;    return from n in _context.NewsPosts&lt;br /&gt;           select new Business.NewsPost(n);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///Same method implementation but in my Mock Repository&lt;br /&gt;public IQueryable GetNewsPosts()&lt;br /&gt;{&lt;br /&gt;     if (this.newsList == null)&lt;br /&gt;     {&lt;br /&gt;        this.newsList = new List()&lt;br /&gt;        {&lt;br /&gt;           new NewsPost() { Body = &amp;quot;News Post 1&amp;quot;, Title = &amp;quot;Test1&amp;quot;, CategoryID = Guid.NewGuid() },&lt;br /&gt;           new NewsPost() { Body = &amp;quot;News Post 2&amp;quot;, Title = &amp;quot;Test2&amp;quot;, CategoryID = Guid.NewGuid() },&lt;br /&gt;           new NewsPost() { Body = &amp;quot;News Post 3&amp;quot;, Title = &amp;quot;Test3&amp;quot;, CategoryID = Guid.NewGuid() }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;    return this.newsList.AsQueryable();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;The error comes when I call everything like so:&lt;/p&gt;

&lt;code&gt;
ConcreteRepository.GetNewsPosts().WithId(someValidGuid);
&lt;/code&gt;

&lt;p&gt;Again, it only fails when calling the real repository.&amp;nbsp; It works fine when using the Mock Code. Any help is greatly appreciated! &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>