<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Encapsulation and LINQ to SQL</title><link>http://blogs.msdn.com/kfarmer/archive/2007/11/13/encapsulation-and-linq-to-sql.aspx</link><description>In my last post I rendered some opinions on how to approach using LINQ to SQL in an encapsulated manner.&amp;#160; In response, several folks requested I put together some more concrete examples.&amp;#160; I have now done so.&amp;#160; Pardon the high code-to-text</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Encapsulation and LINQ to SQL</title><link>http://blogs.msdn.com/kfarmer/archive/2007/11/13/encapsulation-and-linq-to-sql.aspx#7227896</link><pubDate>Fri, 25 Jan 2008 01:11:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7227896</guid><dc:creator>jdavidroberts</dc:creator><description>&lt;p&gt;I really like this approach, but unless I'm missing something, there is a hole in the case of FK relationships. &amp;nbsp;I'm thinking of a case where there is a one-to-many between another entity and Customers. &amp;nbsp;i.e., if a query like the one below is used:&lt;/p&gt;
&lt;p&gt;from sp in db.SalesPeople&lt;/p&gt;
&lt;p&gt;from cust in sp.Customers&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;Maybe I'm missing something, but I'd be interested in your thoughts on the right way to filter Customers &amp;quot;behind the scenes&amp;quot; in this case.&lt;/p&gt;
</description></item><item><title>re: Encapsulation and LINQ to SQL</title><link>http://blogs.msdn.com/kfarmer/archive/2007/11/13/encapsulation-and-linq-to-sql.aspx#7228000</link><pubDate>Fri, 25 Jan 2008 01:21:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7228000</guid><dc:creator>kfarmer@microsoft.com</dc:creator><description>&lt;p&gt;I haven't played around with this in a while. &amp;nbsp;Perhaps instead of a bare EntitySet you could expose a property that returned a filtererd set. &amp;nbsp;The problem I could see would be one of composability -- I'm not sure what sort of expression tree LINQ to SQL would be handed in that case.&lt;/p&gt;
&lt;p&gt;You can also look into DataShape, and how that could be used to preload related items.&lt;/p&gt;
</description></item><item><title>re: Encapsulation and LINQ to SQL</title><link>http://blogs.msdn.com/kfarmer/archive/2007/11/13/encapsulation-and-linq-to-sql.aspx#8239803</link><pubDate>Sun, 16 Mar 2008 13:45:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8239803</guid><dc:creator>Quango</dc:creator><description>&lt;p&gt;Thanks for a very useful article. I'm stuck on one point where I need a more generic query - how can I create my query predicate in a generic way. e.g. my function&lt;/p&gt;
&lt;p&gt;GetEqualQuery(Type entityType, string propName, object value)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;needs to return Expression&amp;lt;Func&amp;lt;TEntity,bool&amp;gt;&amp;gt;&lt;/p&gt;
&lt;p&gt;I have managed to create simple Expression.Equals() expressions but cannot figure out how to create this particular type!&lt;/p&gt;
&lt;p&gt;tia dev @ conficient . com&lt;/p&gt;
</description></item><item><title>WARNING WARNING !!</title><link>http://blogs.msdn.com/kfarmer/archive/2007/11/13/encapsulation-and-linq-to-sql.aspx#8625040</link><pubDate>Fri, 20 Jun 2008 11:22:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8625040</guid><dc:creator>Quango</dc:creator><description>&lt;p&gt;Be VERY careful using this approach.&lt;/p&gt;
&lt;p&gt;I've just found after two months work that LinqDataSource won't let you use the &amp;quot;secure&amp;quot; datacontext for update/insert/delete - because the table properties, e.g. Customers do not return Table&amp;lt;T&amp;gt;, and that is the ONLY type that LINQdatasource will deign to work with. Hence I am trying to figure out a workaround for this but at present it's a major issue.&lt;/p&gt;
</description></item></channel></rss>