<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Linq to SQL with WCF in a Multi Tiered Action - Part 2</title>
	<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html</link>
	<description>still believes in coding to make dreams come true</description>
	<pubDate>Thu, 11 Mar 2010 04:24:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>

	<item>
		<title>By: Sripraks</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-7051</link>
		<dc:creator>Sripraks</dc:creator>
		<pubDate>Thu, 30 Jul 2009 11:54:36 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-7051</guid>
		<description>Hi Sidar,

Nice Article. I have build application using Linq to SQL using the similar approach that you mentioned. But, I have below hurdle.
Our Main Design Goal is WCF service should be very thin. So, we have put all our business logic in to a BO. The BO classes are built with partial classes of Linq To SQL entity classes and has own methods for CRUD operations and validations. The On Top of BO we have build an AL(Activity Layer) which mainly deals with Transactions/Security for BO. The SL calls AL and inturn AL Calls BO and BO uses the LTS to perform necessary operations. Here the problem i see is, i have to expose the LTS entities to all layers which is required in order my Client to work. Since i have tied my BO also with LTS entities via parital class all my static methods are exposed till service layer which i dont want. In this specific case, do you have any ideas to over come this?

More clearly  i can illustrate with an example

Service Layer Method
[Operation Contract]
Public User GetAllUsers(userid)
{
 UserActivity UA = new UserActivity();
 return UA.Getalluser(Userid)
 
 // I can do this as below from here with out AL
 // Return User.Getalluser();
}
 
Activity Layer Method
Public User GetAllUser(userid)
{
 Return User.Getalluser();
}</description>
		<content:encoded><![CDATA[<p>Hi Sidar,</p>
<p>Nice Article. I have build application using Linq to SQL using the similar approach that you mentioned. But, I have below hurdle.<br />
Our Main Design Goal is WCF service should be very thin. So, we have put all our business logic in to a BO. The BO classes are built with partial classes of Linq To SQL entity classes and has own methods for CRUD operations and validations. The On Top of BO we have build an AL(Activity Layer) which mainly deals with Transactions/Security for BO. The SL calls AL and inturn AL Calls BO and BO uses the LTS to perform necessary operations. Here the problem i see is, i have to expose the LTS entities to all layers which is required in order my Client to work. Since i have tied my BO also with LTS entities via parital class all my static methods are exposed till service layer which i dont want. In this specific case, do you have any ideas to over come this?</p>
<p>More clearly  i can illustrate with an example</p>
<p>Service Layer Method<br />
[Operation Contract]<br />
Public User GetAllUsers(userid)<br />
{<br />
 UserActivity UA = new UserActivity();<br />
 return UA.Getalluser(Userid)</p>
<p> // I can do this as below from here with out AL<br />
 // Return User.Getalluser();<br />
}</p>
<p>Activity Layer Method<br />
Public User GetAllUser(userid)<br />
{<br />
 Return User.Getalluser();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sidar Ok</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6849</link>
		<dc:creator>Sidar Ok</dc:creator>
		<pubDate>Thu, 16 Jul 2009 21:23:52 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6849</guid>
		<description>@Prudhvi 

Glad that you found the article useful. Actually if you look at the last code sample in Update, I am doing a context.Attach to enable change tracking. I am attaching the entities that are marked as "dirty" and context tracks what fields are changed and generates the query. So the answer is yes, it is possible but is not fully automatic.</description>
		<content:encoded><![CDATA[<p>@Prudhvi </p>
<p>Glad that you found the article useful. Actually if you look at the last code sample in Update, I am doing a context.Attach to enable change tracking. I am attaching the entities that are marked as &#8220;dirty&#8221; and context tracks what fields are changed and generates the query. So the answer is yes, it is possible but is not fully automatic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prudhvi</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6832</link>
		<dc:creator>Prudhvi</dc:creator>
		<pubDate>Tue, 14 Jul 2009 07:12:24 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6832</guid>
		<description>It's long and detailed which is what most of us need as it has almost everything. Thanks for the article.
I have one question though. What if I want 'change tracking' to be implemented on an object ?
Will it be possible in this disconnected scenario ?</description>
		<content:encoded><![CDATA[<p>It&#8217;s long and detailed which is what most of us need as it has almost everything. Thanks for the article.<br />
I have one question though. What if I want &#8216;change tracking&#8217; to be implemented on an object ?<br />
Will it be possible in this disconnected scenario ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danial</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6593</link>
		<dc:creator>Danial</dc:creator>
		<pubDate>Thu, 04 Jun 2009 12:01:16 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6593</guid>
		<description>My issues are all sorted now!

Thanks for your response.
Danial</description>
		<content:encoded><![CDATA[<p>My issues are all sorted now!</p>
<p>Thanks for your response.<br />
Danial</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sidar Ok</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6483</link>
		<dc:creator>Sidar Ok</dc:creator>
		<pubDate>Tue, 19 May 2009 12:57:57 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6483</guid>
		<description>Hi Danial,

&gt;&gt; One question though, im trying to create a GetSingleUser method but keep running into the “Could not find an implementation of the query pattern for source” i guess this is because User does not implement IQueryable.

I believe you may need to get your type stated explicitly since Linq can not determine your source type to query like done in this post : http://blogs.interakting.co.uk/mattnield/archive/2008/01/25/LINQ-Error-19-Could-not-find-an-implementation-of-the.aspx 

&gt;&gt; My question is what would be the correct way to query a single User say by ID from the database and have it populate the User object.

User u = myDataContext.Users.Single&lt;User&gt;( u =&gt; u.UserId == userIdThatComesAsAParameter);

Where userIdThatComesAsAParameter is always assured to be existing. If you don't want to throw when it is not found, then you can use SingeOrDefault&lt;T&gt;( specification ) and the result will be null when not found.

Hope this helps.</description>
		<content:encoded><![CDATA[<p>Hi Danial,</p>
<p>>> One question though, im trying to create a GetSingleUser method but keep running into the “Could not find an implementation of the query pattern for source” i guess this is because User does not implement IQueryable.</p>
<p>I believe you may need to get your type stated explicitly since Linq can not determine your source type to query like done in this post : <a href="http://blogs.interakting.co.uk/mattnield/archive/2008/01/25/LINQ-Error-19-Could-not-find-an-implementation-of-the.aspx" rel="nofollow" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://blogs.interakting.co.uk/mattnield/archive/2008/01/25/LINQ-Error-19-Could-not-find-an-implementation-of-the.aspx');">http://blogs.interakting.co.uk/mattnield/archive/2008/01/25/LINQ-Error-19-Could-not-find-an-implementation-of-the.aspx</a> </p>
<p>>> My question is what would be the correct way to query a single User say by ID from the database and have it populate the User object.</p>
<p>User u = myDataContext.Users.Single<user>( u => u.UserId == userIdThatComesAsAParameter);</p>
<p>Where userIdThatComesAsAParameter is always assured to be existing. If you don&#8217;t want to throw when it is not found, then you can use SingeOrDefault<t>( specification ) and the result will be null when not found.</p>
<p>Hope this helps.</t></user></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Danial</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6424</link>
		<dc:creator>Danial</dc:creator>
		<pubDate>Thu, 14 May 2009 12:12:32 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-6424</guid>
		<description>Great blog this is exactly what i'm trying to do at the moment.

One question though, im trying to create a GetSingleUser method but keep running into the "Could not find an implementation of the query pattern for source" i guess this is because User does not implement IQueryable.

My question is what would be the correct way to query a single User say by ID from the database and have it populate the User object.

Thanks
Danial</description>
		<content:encoded><![CDATA[<p>Great blog this is exactly what i&#8217;m trying to do at the moment.</p>
<p>One question though, im trying to create a GetSingleUser method but keep running into the &#8220;Could not find an implementation of the query pattern for source&#8221; i guess this is because User does not implement IQueryable.</p>
<p>My question is what would be the correct way to query a single User say by ID from the database and have it populate the User object.</p>
<p>Thanks<br />
Danial</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xon</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-325</link>
		<dc:creator>Xon</dc:creator>
		<pubDate>Sun, 22 Jun 2008 10:49:42 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-325</guid>
		<description>Great article, i resolve all my problems. Thanks for u contritution.</description>
		<content:encoded><![CDATA[<p>Great article, i resolve all my problems. Thanks for u contritution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sidar Ok</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-261</link>
		<dc:creator>Sidar Ok</dc:creator>
		<pubDate>Thu, 12 Jun 2008 09:50:30 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-261</guid>
		<description>Hi Egil, thanks for the comment. 

You are right indeed, that would be probably the way to go in a normal application and what I would do while designing it, thanks for bringing this up. 

While I am on this, as I mentioned in the beginning of the first article (http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-1.html), I didn't want to go down the easy and obvious route, I wanted to keep database as lean as possible and delegate all the logic as a responsibility of application. In some cases you may not want to delete all the child records or you may want to delete them based on a condition - and even roll back if the condition is not satisfied. 

But again, if I was sure that that won't ever be the case, I would push the cascading rules to the db. 

Thanks,

Sidar</description>
		<content:encoded><![CDATA[<p>Hi Egil, thanks for the comment. </p>
<p>You are right indeed, that would be probably the way to go in a normal application and what I would do while designing it, thanks for bringing this up. </p>
<p>While I am on this, as I mentioned in the beginning of the first article (http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-1.html), I didn&#8217;t want to go down the easy and obvious route, I wanted to keep database as lean as possible and delegate all the logic as a responsibility of application. In some cases you may not want to delete all the child records or you may want to delete them based on a condition - and even roll back if the condition is not satisfied. </p>
<p>But again, if I was sure that that won&#8217;t ever be the case, I would push the cascading rules to the db. </p>
<p>Thanks,</p>
<p>Sidar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Egil</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-260</link>
		<dc:creator>Egil</dc:creator>
		<pubDate>Thu, 12 Jun 2008 07:55:42 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-260</guid>
		<description>Interesting article, good work.

One thing that struck me when reading through it was the last part where you update the database.

The hole second part where you update the Favorite table could be much less complicated if you just let the database handle it for you, by putting an "ON DELETE CASCADE" on the foreign key constraint between User and Favorite tables. 

This would automatically delete a favorite if its user was deleted.</description>
		<content:encoded><![CDATA[<p>Interesting article, good work.</p>
<p>One thing that struck me when reading through it was the last part where you update the database.</p>
<p>The hole second part where you update the Favorite table could be much less complicated if you just let the database handle it for you, by putting an &#8220;ON DELETE CASCADE&#8221; on the foreign key constraint between User and Favorite tables. </p>
<p>This would automatically delete a favorite if its user was deleted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WMOC#7: Teched, Velocity - Service Endpoint</title>
		<link>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-244</link>
		<dc:creator>WMOC#7: Teched, Velocity - Service Endpoint</dc:creator>
		<pubDate>Mon, 09 Jun 2008 16:51:35 +0000</pubDate>
		<guid>http://www.sidarok.com/web/blog/content/2008/06/02/linq-to-sql-with-wcf-in-a-multi-tiered-action-part-2.html#comment-244</guid>
		<description>[...] Call Forwarding Via Steve Main WCF Visualizers Paul Stovell Bindable LINQ 1.0 Beta 1 Part 2 of Linq to SQL with WCF in a Multi Tiered Action Mary Jo Foley - More Microsoft ‘Oslo’ modeling details fall into place Sam Gentile New and [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Call Forwarding Via Steve Main WCF Visualizers Paul Stovell Bindable LINQ 1.0 Beta 1 Part 2 of Linq to SQL with WCF in a Multi Tiered Action Mary Jo Foley - More Microsoft ‘Oslo’ modeling details fall into place Sam Gentile New and [&#8230;]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
