<?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>Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx</link><description>Last week .NET RIA services was released. In the release the Asp.NET team has released the Domain Data source control and Dynamic Data support for RIA services.Both the control and Dynamic Data support are the part of the toolkit release of RIA services</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10080384</link><pubDate>Mon, 25 Oct 2010 15:53:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10080384</guid><dc:creator>MarkLIu10</dc:creator><description>&lt;p&gt;Thank you very much. I got it.&lt;/p&gt;
&lt;p&gt;Another problem: Following your blog, I just created an ASP.NET Dynamic Data Domain Service Web application without adding any other code. There is no any problem doing “Edit”, “Update”. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then I create the same application, but using table “Employee” of “AdventureWorks” database. &amp;nbsp;After display “Employees”, I click “Edit”, modified a “Title” column. But I got following error after click “Update”. &lt;/p&gt;
&lt;p&gt;Cannot insert duplicate key row in object &amp;#39;HumanResources.Employee&amp;#39; with unique index &amp;#39;AK_Employee_rowguid&amp;#39;&lt;/p&gt;
&lt;p&gt;But no such error in a Dynamic Data Entity Web application.&lt;/p&gt;
&lt;p&gt;What’s wrong? I didn’t add any code.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10080384" width="1" height="1"&gt;</description></item><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10079989</link><pubDate>Sun, 24 Oct 2010 02:14:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10079989</guid><dc:creator>pranav rastogi</dc:creator><description>&lt;p&gt;The reason you get this exception is that you have multiple Query methods and Dynamic Data need to know which one to use so you have to make one as the default query method. eg&lt;/p&gt;
&lt;p&gt;[Query(IsDefault =true)]&lt;/p&gt;
&lt;p&gt;GetProductsCustomSorting()&lt;/p&gt;
&lt;p&gt;More info about the attribute &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.server.queryattribute(v=VS.91).aspx"&gt;msdn.microsoft.com/.../system.servicemodel.domainservices.server.queryattribute(v=VS.91).aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10079989" width="1" height="1"&gt;</description></item><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10079932</link><pubDate>Sat, 23 Oct 2010 17:35:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10079932</guid><dc:creator>MarkLIu10</dc:creator><description>&lt;p&gt;I first create ASP.NET Dynamic Data Domain Service application, which connect to NorthWind Database. It works like usual. Then following your sample code to add IQueryable&amp;lt;Product&amp;gt; method:&lt;/p&gt;
&lt;p&gt;“public IQueryable&amp;lt;Product&amp;gt; GetProductsCustomSorting(string sortBy)”&lt;/p&gt;
&lt;p&gt;But run default.aspx gets error&lt;/p&gt;
&lt;p&gt;“Cannot find the default query method for type ‘XXX(my type&amp;#39; in the domain service ‘XXXService(My service)&amp;#39;. When a type has multiple query methods associated with it then one of them must be marked as the default one using QueryAttribute.”&lt;/p&gt;
&lt;p&gt;Why? How to set default query method?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10079932" width="1" height="1"&gt;</description></item><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10074032</link><pubDate>Mon, 11 Oct 2010 09:46:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10074032</guid><dc:creator>pranav rastogi</dc:creator><description>&lt;p&gt;Unfortunately I do not have CodeSample handy at this point and would have to build one. You can do Custom buk operations within the domain service as well eg you can put this in Update for Northwind Products which updates all product rows based on a condition&lt;/p&gt;
&lt;p&gt; &amp;nbsp;public void UpdateProduct(Product currentProduct)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;IQueryable&amp;lt;Product&amp;gt; result= this.ObjectContext.Products.Where(p=&amp;gt;p.UnitsInStock&amp;lt;10);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;foreach (Product item in result)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ &amp;nbsp;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;item.Discontinued = true;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;try&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Try to save changes, which may cause a conflict.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int num = this.ObjectContext.SaveChanges();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;catch (OptimisticConcurrencyException)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Resolve the concurrency conflict by refreshing the &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// object context before re-saving changes. &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.ObjectContext.Refresh(RefreshMode.ClientWins, result);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Save changes.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.ObjectContext.SaveChanges();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;catch (UpdateException)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;You can also refer to the following sample which shows how you can do edits on multiple rows using gridview &lt;a rel="nofollow" target="_new" href="http://www.codeproject.com/KB/webforms/BulkEditGridView.aspx"&gt;www.codeproject.com/.../BulkEditGridView.aspx&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You would have to extend this sample to work with Domain Service&lt;/p&gt;
&lt;p&gt;In general I would say that you should use Domain Data source server control if you want to use the Databound controls, but if you do not want to use the control then you could do something as follows.&lt;/p&gt;
&lt;p&gt;Following post shows how you can use DomainService with MVC&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blog.bmdiaz.com/archive/2010/04/03/using-ria-domainservices-with-asp.net-and-mvc-2.aspx"&gt;blog.bmdiaz.com/.../using-ria-domainservices-with-asp.net-and-mvc-2.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can follow the same pattern for creating a domainservice and then bind it to the Gridview without using the DataSource&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10074032" width="1" height="1"&gt;</description></item><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10073106</link><pubDate>Fri, 08 Oct 2010 04:50:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10073106</guid><dc:creator>Don</dc:creator><description>&lt;p&gt;Well basically how to consume the DomainService programmitcally in an ASP.NET page other than just using the DomainDataSource control. &amp;nbsp;An example and an explanation &amp;nbsp;would go a long way. &amp;nbsp;Do you have any samples I could see? &amp;nbsp;I am just trying to get past this one last hurdle...also do you need to do anything special to instantiate the DomainService in ASP.NET code behind? &amp;nbsp;I&amp;#39;m not sure whether I am instantiating the service correctly....&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10073106" width="1" height="1"&gt;</description></item><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10072578</link><pubDate>Thu, 07 Oct 2010 06:03:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10072578</guid><dc:creator>pranav rastogi</dc:creator><description>&lt;p&gt;@Don: &amp;nbsp;You are correct in your understanding. The Domain service scenario works differently in Aspnet application vs Silverlight. In AspNet there is no Client generated so you are working with the Domain Service directly. And when you use Databound control with DomainDatSource, you are limited to a single row update by default. That being said you can have a CustomUpdate method fired in the DomainService which could update more than 1 row of the entity provided that you handle the SaveChanges(). Following linek shows you how to use SaveChanges &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/bb336792.aspx"&gt;msdn.microsoft.com/.../bb336792.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regarding documentation we have something in works which would add to the existing ones and I would like to hear from you on what is missing currently.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10072578" width="1" height="1"&gt;</description></item><item><title>re: Using Domain Service with ASP.NET Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10072292</link><pubDate>Wed, 06 Oct 2010 16:13:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10072292</guid><dc:creator>Don</dc:creator><description>&lt;p&gt;So I wanted to implement a &amp;quot;bulk&amp;quot; insert in my domain service. &amp;nbsp;I am using Dynamic Data and ASP.NET...all the domain service examples I have seen refer to using Client generated Object Context class in SIlverlight examples...I&amp;#39;m guess this isn&amp;#39;t applying to my case since all the processing I am doing with DD is happening server side....so would i just add my custom bulk methods to my Domain Service class and add the &amp;lt;ignore&amp;gt;_ attribute...is this save? &amp;nbsp;Also would I explicistly have to call SaveChanges() ? &amp;nbsp;The docs for Silverlight are good but as this applies to Dynamic Data and ASP.NET I have to save only very basic examples are covered....&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10072292" width="1" height="1"&gt;</description></item><item><title>Using a DomainService in ASP.NET and Dynamic Data</title><link>http://blogs.msdn.com/b/pranav_rastogi/archive/2010/05/22/using-domain-service-with-asp-net-dynamic-data.aspx#10070772</link><pubDate>Fri, 27 Aug 2010 00:11:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10070772</guid><dc:creator>Angle Bracket Percent</dc:creator><description>&lt;p&gt;Update (8/26/2010): I updated some of the content to reflect the new way to get the bits. &amp;#160; One&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10070772" width="1" height="1"&gt;</description></item></channel></rss>