<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.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>ASP.NET Weblogs</title><link>http://weblogs.asp.net/default.aspx?GroupID=4</link><description>ASP.NET Community Bloggers</description><dc:language>en-US</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>modern.ie</title><link>http://weblogs.asp.net/lichen/archive/2013/05/17/modern-ie.aspx</link><pubDate>Fri, 17 May 2013 01:33:21 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10298491</guid><dc:creator>dotneteer</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;We are planning to update our very old web application so that it works better with modern web browsers. I have heard of &lt;a href="http://modern.ie"&gt;modern.ie&lt;/a&gt; in the past and decided to give it a try. The site has a scanner that can scan a URL entered by a user. Unfortunately, our site requires log-in before getting to the page we want to scan. Fortunately, the site also offers a &lt;a href="http://virtualization.modern.ie/vhd/modern.ie.zip?10e3374d847343a78531a3fd386598a8"&gt;downloadable scanner&lt;/a&gt; that we can use in our local development environment.&lt;/p&gt;  &lt;p&gt;I downloaded the scanner. It is packaged as a zip file. I unzipped the package and open the readme file. The tools requires node.js to work. Fortunately, it is fairly easy to setup the tool following the instructions. Firstly, download and install &lt;a href="http://nodejs.org/"&gt;node.js&lt;/a&gt;; accept all defaults. The setup will add Node.js to the path. Although Node.js is known for hosting asynchronous web applications, it is actually just a javascript executing environment. Next, I open the command prompt, change to the directory that I unzipped the modern.ie tool and run “node lib/service.js”. A node hosted web server is listening on port 1337 so we just need to open a web browser and points to &lt;a title="http://localhost:1337/" href="http://localhost:1337/"&gt;http://localhost:1337/&lt;/a&gt;. We can then enter the URL of a web page to scan. The scanner submits the data to modern.ie and a report is generated. The report is very good and it offers many suggestions and links that helps us to improve the page.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10298491" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/lichen/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/lichen/archive/tags/Javascript/default.aspx">Javascript</category></item><item><title>Red Gate Is Looking For Feedback On Its ASP.NET MVC Web Development Education Website</title><link>http://weblogs.asp.net/paulomorgado/archive/2013/05/16/red-gate-is-looking-for-feedback-on-its-asp-net-mvc-web-development-education-website.aspx</link><pubDate>Thu, 16 May 2013 22:43:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10298097</guid><dc:creator>Paulo Morgado</dc:creator><slash:comments>1</slash:comments><description>&lt;p align="justify"&gt;&lt;a target="_blank" href="http://www.red-gate.com/" title="redgate - ingeniously simple tools"&gt;Red Gate&lt;/a&gt; is looking for feedback on its &lt;a target="_blank" href="http://webdev.simple-talk.com/" title="Simple-Talk: Web Developers"&gt;ASP.NET Web Development Education&lt;/a&gt; website.&lt;/p&gt;
&lt;p align="justify"&gt;Visit their website and answer the &lt;a target="_blank" href="https://www.surveymk.com/s/B7GS522" title=".NET Publishing Feedback Survey"&gt;survey&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10298097" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/paulomorgado/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://weblogs.asp.net/paulomorgado/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/paulomorgado/archive/tags/redgate/default.aspx">redgate</category><category domain="http://weblogs.asp.net/paulomorgado/archive/tags/Web/default.aspx">Web</category></item><item><title>World's largest startup competition and hackathon (AngelHack 2013) comes to Singapore in June 2013</title><link>http://weblogs.asp.net/darrensim/archive/2013/05/15/world-s-largest-startup-competition-and-hackathon-angelhack-2013-comes-to-singapore-in-june-2013.aspx</link><pubDate>Tue, 14 May 2013 15:59:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10287414</guid><dc:creator>Darren.Sim</dc:creator><slash:comments>0</slash:comments><description>Entrepreneurship has been on the rise in sunny Singapore over the past years with more and more youths having the guts to take the bold step to be different - stepping out of the comforts of a stable &lt;strong&gt;9am to 5pm&lt;/strong&gt; desk job to realize their dreams.

Although I'm still fairly un-impressed with our startup scene here (in comparison with the US, or something closer to home - China and Korea), I am happy to say that things are going better and instead of complaining, many Singaporeans are taking the step to improve things at home after returning from the valley.
&lt;p style="text-align: center;"&gt;&lt;a href="https://www.facebook.com/AngelHackSingapore" target="_blank"&gt;&lt;img class="alignnone" alt="" src="http://farm8.staticflickr.com/7432/8731066119_1f33a0bb15_z.jpg" width="610" height="458" /&gt;&lt;/a&gt;
&lt;strong style="font-size: x-small; text-align: center;"&gt;Photo Credits&lt;/strong&gt;&lt;span style="font-size: x-small; text-align: center;"&gt;: &lt;/span&gt;&lt;span style="font-size: x-small; text-align: center;"&gt;sgentrepreneurs.com &amp;amp; darrensim.com&lt;/span&gt;&lt;/p&gt;
When talking about entrepreneurship in Singapore, we definitely cannot go without mentioning people like &lt;em&gt;&lt;strong&gt;&lt;a href="http://en.wikipedia.org/wiki/Meng_Weng_Wong" target="_blank"&gt;Wong Meng Meng&lt;/a&gt; &lt;/strong&gt;&lt;/em&gt;and&lt;strong&gt;&lt;/strong&gt;&lt;em&gt;&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;&lt;em&gt;&lt;strong&gt;&lt;a href="http://en.wikipedia.org/wiki/Sim_Wong_Hoo" target="_blank"&gt;Sim Wong Hu&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt; who decided to call Singapore home despite their success overseas.
&lt;p style="text-align: center;"&gt;&lt;a href="https://www.facebook.com/AngelHackSingapore" target="_blank"&gt;&lt;img class="alignnone" alt="" src="http://farm8.staticflickr.com/7434/8731105231_7e21cb26c2_z.jpg" width="610" height="466" /&gt;&lt;/a&gt;
&lt;span style="font-size: x-small;"&gt;&lt;strong&gt;Photo Credits&lt;/strong&gt;: http://www.todayonline.com/business/sme/gushing-ambition&lt;/span&gt;&lt;/p&gt;
Of course how can we not have a mention of &lt;strong&gt;GushCloud &lt;/strong&gt;- one of Singapore's hottest startup properties?

I first heard about GushCloud when I attended the &lt;strong&gt;Startup Asia Singapore&lt;/strong&gt; conference last year; and their booth was so packed that I've to give it a miss to check out what they were up to. My real interaction with &lt;strong&gt;GushCloud&lt;/strong&gt; only began while I was in a PR &amp;amp; Business development role that dealt with bloggers. Man, I must say that dealing with &lt;strong&gt;GushCloud &lt;/strong&gt;was such a positive experience that I told Freda (from GushCloud) that if one day my blog ever has people reading it and it was good enough to be managed by a blogger management agency, I will queue overnight at their doors and beg for shelter under their wings.

You would think that this is all some kind of cult; you bet I thought the same way too. But it was only when I met and chatted with &lt;strong&gt;GushCloud &lt;/strong&gt;founders Vincent and Althea (thank you Sheena, without you, this would never have been possible) that I understand why. It's the drive and passion in them that generated this transfusion of positive forces that inspires and invigorates the entire company.

I will not attempt to claim that I know them too well, but just a short chat with any of them and you will feel the vibes.

&lt;a href="https://www.facebook.com/AngelHackSingapore" target="_blank"&gt;&lt;img alt="" src="http://www.darrensim.com/wp-content/uploads/2013/05/Untitled-1.jpg" width="610" height="270" /&gt;&lt;/a&gt;

Come June 2013, &lt;strong&gt;GushCloud &lt;/strong&gt;will be hosting the world's largest Hackathon in Singapore at the Amazon HQ Singapore.
&lt;p style="text-align: center;"&gt;&lt;a href="https://www.facebook.com/AngelHackSingapore" target="_blank"&gt;&lt;img class="alignnone" alt="" src="http://farm8.staticflickr.com/7336/8732318452_37bab55f28.jpg" width="420" height="300" /&gt;&lt;/a&gt;
&lt;span style="font-size: x-small;"&gt;&lt;strong&gt;Photo Credits&lt;/strong&gt;: outsideinmarketing.wordpress.com&lt;/span&gt;&lt;/p&gt;
&lt;p style="text-align: left;"&gt;Basically if you've not already heard about it, a hackathon is an event where like minded people come together to "hack together" something and make it work in a very short period of time. The objectives of such sessions is not to produce something that you can readily sell to people, but rather a &lt;em&gt;&lt;strong&gt;working proof-of-concept&lt;/strong&gt;&lt;/em&gt; of an idea, that allows others to visualize and actually test the idea using a working model.&lt;/p&gt;
&lt;p style="text-align: center;"&gt;&lt;a href="https://www.facebook.com/AngelHackSingapore" target="_blank"&gt;&lt;img alt="" src="http://farm8.staticflickr.com/7294/8732318558_7b47374b6f_b.jpg" width="610" /&gt;&lt;/a&gt;
&lt;span style="font-size: x-small;"&gt;&lt;strong&gt;Photo &lt;/strong&gt;&lt;/span&gt;&lt;strong style="font-size: x-small;"&gt;Credits&lt;/strong&gt;&lt;span style="font-size: x-small;"&gt;: visual.ly &lt;/span&gt;&lt;/p&gt;
&lt;p style="text-align: left;"&gt;People who attends such sessions includes veterans as well as newbies, who attends hackathons mainly for learning, meeting new people and hoping to do their parts to change the world.&lt;/p&gt;

Read the entire post via &lt;a href="http://www.darrensim.com/2013/05/14/worlds-largest-startup-competition-and-hackathon-angelhack-2013-comes-to-singapore-in-june-2013/"&gt;http://www.darrensim.com/2013/05/14/worlds-largest-startup-competition-and-hackathon-angelhack-2013-comes-to-singapore-in-june-2013/&lt;/a&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10287414" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/darrensim/archive/tags/Careers/default.aspx">Careers</category><category domain="http://weblogs.asp.net/darrensim/archive/tags/Community+News/default.aspx">Community News</category><category domain="http://weblogs.asp.net/darrensim/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/darrensim/archive/tags/Management/default.aspx">Management</category><category domain="http://weblogs.asp.net/darrensim/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Consuming  Windows Azure Mobile Services REST API from ASP.NET Web API App</title><link>http://weblogs.asp.net/shijuvarghese/archive/2013/05/12/consuming-windows-azure-mobile-services-rest-api-from-asp-net-web-api-app.aspx</link><pubDate>Sun, 12 May 2013 09:59:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10276779</guid><dc:creator>shiju</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;&lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services lets the developers to use structured storage, user authentication and push notifications to Android, iOS, HTML, Windows Store, or Windows Phone 8 apps&amp;#160; by leveraging the Windows Azure Cloud platform. Using with &lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services, you can enjoy the scalability power of Cloud to your Mobile apps. In this blog post, I will demonstrate how to persist data on Windows Azure Mobile Services Table from a ASP.NET Web API app by leveraging the Windows Azure Mobile Services REST API, and finally provides a generic type helper class for performing CRUD operations on the Windows Azure Mobile Services Table.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4" face="Calibri"&gt;&lt;strong&gt;Consuming Windows Azure Mobile Services REST API from a ASP.NET Web API App&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services provides native API for Android, iOS, HTML, Windows Store, or Windows Phone 8 apps&amp;#160; so that you can directly consume the &lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services from your native Mobile apps. In this post, we will be consume the &lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services from a&amp;#160; ASP.NET Web API app. &lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services provides REST API so that we can easily consume it form our ASP.NET Web API app. This use case is based on a real world app I have recently worked, where iOS clients are consuming a REST API written in ASP.NET Web API and for some persistence over the REST API, we need to send push notifications to the iOS clients. So we are consuming the Windows Azure Mobile Services REST API from ASP.NET Web API app where we need to send push notifications. In this post, I am directly consuming the REST API from my app instead of using any REST API wrapper for .Net clients so that we can explore the &lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services &lt;/font&gt;REST API.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4" face="Calibri"&gt;&lt;strong&gt;A Generic CRUD Helper Class for Windows Azure Mobile Services Table&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;Let’s create a generic type class for CRUD operations on the Windows Azure Mobile Services Table by consuming the REST API of &lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services. This generic type helper class can work with any type of Model object.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c67ee718-09a0-4157-a1ec-edeb20fa0876" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceRequestHelper&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;T&amp;gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;where&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; T : &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; tableEndpoint;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; applicationKey;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; client;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; MobileServiceRequestHelper(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; tableName)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;tableEndpoint = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ConfigurationManager&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;.AppSettings[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;TableEndpoint&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;] + tableName ;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;applicationKey = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ConfigurationManager&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;.AppSettings[&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;X-ZUMO-APPLICATION&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;];&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;client = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpClient&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;client.DefaultRequestHeaders.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;Add(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;X-ZUMO-APPLICATION&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, applicationKey);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;client.DefaultRequestHeaders.Accept&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;.Add(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MediaTypeWithQualityHeaderValue&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;));&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;We are taking the application key and Mobile Services URI from the web.config table and we will pass the Windows Azure Table name in the constructor method of our generic type helper class.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;strong&gt;Insert Operation&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The API documentation for Insert record operation available from &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj677200.aspx" target="_blank"&gt;here&lt;/a&gt;. The code block below provides the implementation of HTTP Post for inserting a new record onto Windows Azure Mobile Services Table. We are serializing the model object as JSON format and executing the HTTP request by calling the SendAsync method of HTTPClient class.&lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7bc193b-5d69-4780-a02a-f1949e1da3ed" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;bool&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Post(T requestData)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; obj = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonConvert&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.SerializeObject(requestData,&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonSerializerSettings&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;()&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;NullValueHandling = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;NullValueHandling&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Ignore&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; request = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpRequestMessage&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpMethod&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Post,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;tableEndpoint);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;request.Content = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;StringContent&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(obj, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Encoding&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.UTF8,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data = client.SendAsync(request).Result;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (data.IsSuccessStatusCode)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpResponseException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(data.StatusCode);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;strong&gt;Update Operation&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The API documentation for Update record operation available from &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj677198.aspx" target="_blank"&gt;here&lt;/a&gt;. The code block below provides the implementation of HTTP Put for updating an existing record onto Windows Azure Mobile Services Table. &lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:06414e53-f23e-471f-9297-c6cc432e9aae" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;bool&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Put(T requestData, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; id)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; request = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpRequestMessage&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpMethod&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;PATCH&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;), &lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;tableEndpoint + id);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; obj = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonConvert&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.SerializeObject(requestData);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;request.Content = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;StringContent&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(obj, &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Encoding&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.UTF8, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;application/json&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data = client.SendAsync(request).Result;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (data.IsSuccessStatusCode)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpResponseException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(data.StatusCode);     &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;Please note that Windows Azure Mobile Services used HTTP Verb “PATCH” for updating an existing record.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;strong&gt;Delete Operation&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The API documentation for Delete record operation available from &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj710107.aspx" target="_blank"&gt;here&lt;/a&gt;. The code block below provides the implementation of HTTP Delete for deleting an existing record from the Windows Azure Mobile Services Table. &lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:22339e7e-b658-43b6-a102-a56aefbcfbba" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Delete(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; id)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; request = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpRequestMessage&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpMethod&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Delete, &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;tableEndpoint + id.ToString());&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data = client.SendAsync(request).Result;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (!data.IsSuccessStatusCode)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpResponseException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(data.StatusCode);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;strong&gt;Query Operation&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The API documentation for Query record operation available from &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj677199.aspx" target="_blank"&gt;here&lt;/a&gt;. The code block below provides the implementation of querying all records and filtering with id value from the Windows Azure Mobile Services Table. &lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:89643fcb-85a3-4441-802e-fc074c476f43" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;IEnumerable&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;T&amp;gt; GetAll()&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result = client.GetStringAsync(tableEndpoint).Result;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonConvert&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.DeserializeObject&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;IEnumerable&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;T&amp;gt;&amp;gt;(result);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data; &lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; T Get(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; id)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; result = client.GetStringAsync(tableEndpoint +&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;?$filter=Id eq &amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + id).Result;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonConvert&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.DeserializeObject&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;IEnumerable&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;T&amp;gt;&amp;gt;(result);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; data.FirstOrDefault();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;} &lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;Windows Azure Mobile Services supports the Open Data Protocol (OData) so that you can query the data from Windows Azure Mobile Services Table by using the query option parameters provided by the OData.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The complete implementation of the MobileServiceRequestHelper class is available on Gist at &lt;a href="https://gist.github.com/shijuvar/5562928"&gt;https://gist.github.com/shijuvar/5562928&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4" face="Calibri"&gt;&lt;strong&gt;Consuming the REST API from ASP.NET Web API App&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;In the previous steps, we have created a generic type helper class for executing requests against Windows Azure Mobile Services REST API. The code block below provides the HTTP Post operation of our ASP.NET Web API where we inserting a new record onto Windows Azure Mobile Services table named “tokens”&lt;/font&gt;&lt;/p&gt;  &lt;div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ee5bcd10-2f23-44da-b3b6-f941156edcc8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #ddd; max-height: 400px; overflow: auto"&gt; &lt;ol start="1" style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpResponseMessage&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Post(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Token&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; token)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (ModelState.IsValid)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; req = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;MobileServiceRequestHelper&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Token&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;tokens&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; isSuccess = req.Post(token);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (isSuccess)&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpResponseMessage&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; response = Request.CreateResponse(&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpStatusCode&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Created, token);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;            &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; response;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;throw&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpResponseException&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpStatusCode&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.BadRequest);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;else&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Request.CreateErrorResponse(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpStatusCode&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.BadRequest, ModelState);&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;In the above code block, we are creating an object of MobileServiceRequestHelper with generic type Token and inserting a new record on Windows Azure Mobile Services table “tokens”.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10276779" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/ASP.NET+Web+API/default.aspx">ASP.NET Web API</category><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/Azure/default.aspx">Azure</category><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/Windows+Azure/default.aspx">Windows Azure</category><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/.Net/default.aspx">.Net</category></item><item><title>Creating a simple Live Cricket Score using ASP.NET SignalR</title><link>http://weblogs.asp.net/imranbaloch/archive/2013/05/11/creating-a-simple-live-cricket-score-using-asp-net-signalr.aspx</link><pubDate>Sat, 11 May 2013 14:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10272909</guid><dc:creator>imran_ku07</dc:creator><slash:comments>3</slash:comments><description>&lt;p mce_keep="true"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;Introduction:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;br&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt; &lt;/p&gt;

&lt;p mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am from Pakistan. Like most of Pakistanis, I am also a huge fan of Cricket. Yesterday, I got some time from my busy&amp;nbsp;job.&amp;nbsp;I thought to create a simple Cricket Live Score feature using ASP.NET SignalR. It is also Interesting to note that the guys(David Fowler from West Indies&amp;nbsp;and Damian Edwards from Australia) that are heavily involved in SignalR development are also cricket fans(correct me if I am wrong).&amp;nbsp;&amp;nbsp;In this article, I will show&amp;nbsp;you how to create a simple 'Live Cricket Score' feature using SignalR. For&amp;nbsp;a quick demo, just open &lt;a href="http://109.73.74.20/CricketDemo/pakistan-vs-india.html" mce_href="http://109.73.74.20/CricketDemo/pakistan-vs-india.html"&gt;this link&lt;/a&gt; in&amp;nbsp;different browsers and in one browser just append&amp;nbsp;&lt;em&gt;?admin=&lt;/em&gt;&amp;nbsp;query-string(which will become the admin who update the score), then just click &lt;em&gt;Update Score&lt;/em&gt; button many times until 2 overs finish(the match will be limited&amp;nbsp;to 2 overs). For each click, the live score will be updated in&amp;nbsp;each browser.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt; &lt;/p&gt;
&lt;br&gt;
&lt;p&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;Description:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&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; &lt;img style="width: 785px; height: 687px;" border="1" align="middle" src="http://weblogs.asp.net/blogs/imranbaloch/Cricket.png" width="785" height="687" mce_src="http://weblogs.asp.net/blogs/imranbaloch/Cricket.png"&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;u&gt;&lt;/u&gt;&lt;/b&gt; &lt;/p&gt;
&lt;br&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you are new to SignalR then &lt;a href="http://www.asp.net/signalr" mce_href="http://www.asp.net/signalr"&gt;Getting Started&lt;/a&gt; will be great for you. Assuming that you have configured your application with ASP.NET SignalR.&amp;nbsp;Let create a simple html page with following lines,&lt;/p&gt;
&lt;br&gt;
&lt;pre class="brush:xhtml"&gt;        
        &amp;lt;!DOCTYPE html&amp;gt;
        &amp;lt;html&amp;gt;
        &amp;lt;head&amp;gt;
            &amp;lt;title&amp;gt;Pakistan v/s India&amp;lt;/title&amp;gt;
            &amp;lt;style&amp;gt;
                .team
                {
                    font-size: 15px;
                    padding-right: 10px;
                    font-weight: bold;
                    text-transform: capitalize;
                }
                .wickets,overs
                {
                    padding-right: 5px;
                }
            &amp;lt;/style&amp;gt;
        &amp;lt;/head&amp;gt;
        &amp;lt;body&amp;gt;
            &amp;lt;h1&amp;gt;Pakistan v/s India&amp;lt;/h1&amp;gt;
            &amp;lt;div id="updateScore" style="display: none;"&amp;gt;
                &amp;lt;input type="button" id="updateScoreLink" value="Update Score"/&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;br /&amp;gt;
            &amp;lt;div data-bind="foreach: teams"&amp;gt;
                &amp;lt;div&amp;gt;
                    &amp;lt;span class="team" data-bind="{ html: team }"&amp;gt;&amp;lt;/span&amp;gt;
                    &amp;lt;span class="runs" data-bind="{ html: runs }"&amp;gt;&amp;lt;/span&amp;gt;/&amp;lt;span class="wickets" data-bind="{ html: wickets }"&amp;gt;&amp;lt;/span&amp;gt;
                    &amp;lt;b&amp;gt;Overs&amp;lt;/b&amp;gt; &amp;lt;span class="overs" data-bind="{ html: oversText }"&amp;gt;&amp;lt;/span&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;script src="Scripts/jquery-1.8.2.min.js" &amp;gt;&amp;lt;/script&amp;gt;
            &amp;lt;script src="Scripts/jquery.signalR-1.0.1.min.js"&amp;gt;&amp;lt;/script&amp;gt;
            &amp;lt;script src="signalr/hubs"&amp;gt;&amp;lt;/script&amp;gt;
            &amp;lt;script src="Scripts/knockout-2.2.0.js" &amp;gt;&amp;lt;/script&amp;gt;
            &amp;lt;script type="text/javascript"&amp;gt;
                // Here we start
            &amp;lt;/script&amp;gt;
        &amp;lt;/body&amp;gt;
        &amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;br&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In the above page,&amp;nbsp;we have&amp;nbsp;referenced jquery, signalr and knockout scripts.&amp;nbsp;We have also define a simple template which will show the runs, wickets&amp;nbsp;and overs of both teams. For demo purpose,&amp;nbsp;we have&amp;nbsp;added a&amp;nbsp;&lt;em&gt;Update Score&lt;/em&gt; button in the page. This button when clicked&amp;nbsp;will&amp;nbsp;record&amp;nbsp;a single ball of an over&amp;nbsp;as well as&amp;nbsp;runs scored in this ball . After each ball, I will tell&amp;nbsp;SignalR to broadcast teams score-card across all the connected client. When the match finished(after 24 balls), I will again tell the SignalR to show the final result to all users. Here are the scripts which are required for our work, &lt;/p&gt;
&lt;br&gt;
&lt;pre class="brush:xhtml"&gt;  
        $(function () {
            var chat = $.connection.cricketHub,
                viewModel = {
                    teams: ko.observableArray([
                    { team: 'india', runs: 0, wickets: 0, balls: 0, oversText: '0.0' },
                    { team: 'pakistan', runs: 0, wickets: 0, balls: 0, oversText: '0.0'}])
                },
                index = 0;// index represant the position of the current batting team
            chat.client.updateScore = function (t) {
                viewModel.teams(JSON.parse(t));
            };
            chat.client.matchFinished = function (result) {
                alert(result);
            };
            $.connection.hub.start().done(function () {
                $('#updateScoreLink').click(function () {
                    var teams = viewModel.teams(),
                        team1 = teams[index],
                        team2 = teams[(index + 1) % 2],
                        wicketFalled = getRandomInt(0, 5) == 3 ? true : false;
                    // Assuming that the wicket will only fall when  a 0-5 random number is 3
                    team1.runs += getRandomInt(0, 6); // Get a random score between 0 to 6
                    team1.wickets += wicketFalled ? 1 : 0;
                    team1.balls += 1;
                    team1.oversText = truncate(team1.balls / 6).toString() + '.' + (team1.balls % 6).toString();
                    chat.server.updateScore(JSON.stringify(teams));
                    if (team1.balls === 12 &amp;amp;&amp;amp; team2.balls === 12) {
                        $('#updateScoreLink').hide();
                        var message = (team1.runs &amp;gt; team2.runs ? team1.team : team2.team) + ' won';
                        message = team1.runs === team2.runs ? 'match tied' : message;
                        message += '\n' + team1.team + ': ' + team1.runs + '/' + team1.wickets + ' overs: ' + team1.oversText;
                        message += '\n' + team2.team + ': ' + team2.runs + '/' + team2.wickets + ' overs: ' + team2.oversText;
                        chat.server.matchFinished(message);
                    }
                    else if (team1.balls === 12) {
                        index = 1;// second team batting
                    }
                    viewModel.teams([team1,team2]);
                });
            });
            ko.applyBindings(viewModel);
            if (isAdmin()) {
                $('#updateScore').show();
            }
            
            function getRandomInt(min, max) {
                return Math.floor(Math.random() * (max - min + 1)) + min;
            }
            function truncate(n) {
                return Math[n &amp;gt; 0 ? "floor" : "ceil"](n);
            }
            function isAdmin(){
                // For demo, assuming that only admin can update the score 
                // and the admin will be user which have admin querystring.
                return location.href.indexOf('admin=') &amp;gt; -1
            }
        });
&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In the above scripts,&amp;nbsp;we are&amp;nbsp;initializing SignalR hub cricketHub object(we will see this hub class shortly),&amp;nbsp;viewModel object which include team information(runs, wickets, etc) and index which represent the current batting team. Next, we have two client functions(updateScore and matchFinished) which will be invoked when the server broadcast a message to all clients.&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;When the hub start, we are registering event handler&amp;nbsp;&lt;em&gt;Update Score&lt;/em&gt; click event where we are getting a random run between 0-6, a&amp;nbsp;wicket or not depending upon a random number, updating&amp;nbsp;our view-model and then telling SignalR to broadcast the view-model across all the connected clients so that all clients automatically update their scorecard. Finally, when both teams&amp;nbsp;completed their 12 balls, we will send the results to all the connected clients using SignalR. Note that for demo purpose we are only showing the &lt;em&gt;Update Score&lt;/em&gt; button to the user which have &lt;em&gt;admin=&lt;/em&gt; query-string.&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Finally, here is&amp;nbsp;our CricketHub class,&lt;/p&gt;
&lt;br&gt;
&lt;pre class="brush:csharp"&gt;        
    public class CricketHub : Hub
    {
        public void UpdateScore(string teams)
        {
            Clients.All.UpdateScore(teams);
        }
        public void MatchFinished(string result)
        {
            Clients.All.MatchFinished(result);
        }
    }
&lt;/pre&gt;
&lt;br&gt;



&lt;p&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;b&gt;&lt;u&gt;Summary:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;br&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In this article, I showed you one of&amp;nbsp;the usage of ASP.NET SignalR. You have seen that how easily we can create a&amp;nbsp;real-time Live Cricket Score using the power of ASP.NET SignalR which works in every browser .&amp;nbsp;Hopefully you will enjoy my this article too.&lt;/p&gt;
&lt;br&gt;
&lt;br&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10272909" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/imranbaloch/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/imranbaloch/archive/tags/jQuery/default.aspx">jQuery</category><category domain="http://weblogs.asp.net/imranbaloch/archive/tags/SignalR/default.aspx">SignalR</category></item><item><title>Entity Framework Code First Fluent Validation</title><link>http://weblogs.asp.net/ricardoperes/archive/2013/05/09/entity-framework-code-first-fluent-validation.aspx</link><pubDate>Thu, 09 May 2013 18:56:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10264842</guid><dc:creator>Ricardo Peres</dc:creator><slash:comments>3</slash:comments><description>&lt;p align="justify"&gt;Back to Entity Framework Code First (EFCF) validation. On my &lt;a href="http://weblogs.asp.net/ricardoperes/archive/2013/05/09/entity-framework-code-first-validation.aspx" target="_blank"&gt;previous post&lt;/a&gt; I mentioned that EFCF did not support fluent validation. While this is true, it isn’t too hard to implement one such mechanism, which is exactly why I am writing this! &lt;img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Smile" src="http://weblogs.asp.net/blogs/ricardoperes/wlEmoticon-smile_5F1A75D4.png" /&gt;&lt;/p&gt;  &lt;p align="justify"&gt;I will be using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savingchanges.aspx" target="_blank"&gt;SavingChanges&lt;/a&gt; event to inject the validation logic, which will be implemented by strongly typed delegates. Let’s see some code:&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;   &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;     &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; DbContextExtensions&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; IDictionary&amp;lt;Type, Tuple&amp;lt;Delegate, String&amp;gt;&amp;gt; entityValidations = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ConcurrentDictionary&amp;lt;Type, Tuple&amp;lt;Delegate, String&amp;gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddEntityValidation&amp;lt;TEntity&amp;gt;(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; DbContext context, Func&amp;lt;TEntity, Boolean&amp;gt; validation, String message) &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; TEntity : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (context == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span style="color: #006080"&gt;&amp;quot;context&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (validation == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span style="color: #006080"&gt;&amp;quot;validation&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (String.IsNullOrWhiteSpace(message) == &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ArgumentNullException(&lt;span style="color: #006080"&gt;&amp;quot;message&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (entityValidations.ContainsKey(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TEntity)) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;             (context &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; IObjectContextAdapter).ObjectContext.SavingChanges += &lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (context.Configuration.ValidateOnSaveEnabled == &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum27" style="color: #606060"&gt;  27:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum28" style="color: #606060"&gt;  28:&lt;/span&gt;                     IEnumerable&amp;lt;TEntity&amp;gt; entities = context.ChangeTracker.Entries&amp;lt;TEntity&amp;gt;().Where(x =&amp;gt; x.State == EntityState.Added || x.State == EntityState.Modified).Select(x =&amp;gt; x.Entity).ToList();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum29" style="color: #606060"&gt;  29:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum30" style="color: #606060"&gt;  30:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (TEntity entity &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; entities)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum31" style="color: #606060"&gt;  31:&lt;/span&gt;                     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum32" style="color: #606060"&gt;  32:&lt;/span&gt;                         String error = ValidateEntity(entity);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum33" style="color: #606060"&gt;  33:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum34" style="color: #606060"&gt;  34:&lt;/span&gt;                         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (String.IsNullOrWhiteSpace(error) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum35" style="color: #606060"&gt;  35:&lt;/span&gt;                         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum36" style="color: #606060"&gt;  36:&lt;/span&gt;                             &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ValidationException(error));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum37" style="color: #606060"&gt;  37:&lt;/span&gt;                         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum38" style="color: #606060"&gt;  38:&lt;/span&gt;                     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum39" style="color: #606060"&gt;  39:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum40" style="color: #606060"&gt;  40:&lt;/span&gt;             };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum41" style="color: #606060"&gt;  41:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum42" style="color: #606060"&gt;  42:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum43" style="color: #606060"&gt;  43:&lt;/span&gt;         entityValidations[&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TEntity)] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Tuple&amp;lt;Delegate, String&amp;gt;(validation, message);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum44" style="color: #606060"&gt;  44:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum45" style="color: #606060"&gt;  45:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum46" style="color: #606060"&gt;  46:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; String ValidateEntity&amp;lt;TEntity&amp;gt;(TEntity entity)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum47" style="color: #606060"&gt;  47:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum48" style="color: #606060"&gt;  48:&lt;/span&gt;         Type entityType = &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(TEntity);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum49" style="color: #606060"&gt;  49:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum50" style="color: #606060"&gt;  50:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (entityValidations.ContainsKey(entityType) == &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum51" style="color: #606060"&gt;  51:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum52" style="color: #606060"&gt;  52:&lt;/span&gt;             Tuple&amp;lt;Delegate, String&amp;gt; entry = entityValidations[entityType];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum53" style="color: #606060"&gt;  53:&lt;/span&gt;             Func&amp;lt;TEntity, Boolean&amp;gt; validation = entry.Item1 &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; Func&amp;lt;TEntity, Boolean&amp;gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum54" style="color: #606060"&gt;  54:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum55" style="color: #606060"&gt;  55:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (validation(entity) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum56" style="color: #606060"&gt;  56:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum57" style="color: #606060"&gt;  57:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (entry.Item2);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum58" style="color: #606060"&gt;  58:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum59" style="color: #606060"&gt;  59:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum60" style="color: #606060"&gt;  60:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum61" style="color: #606060"&gt;  61:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum62" style="color: #606060"&gt;  62:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum63" style="color: #606060"&gt;  63:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;We have an extension method that allows declaring, for an entity type, a validation expression, such as this:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; ctx.AddEntityValidation&amp;lt;SomeEntity&amp;gt;(x =&amp;gt; x.SomeProperty != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;SomeProperty is required&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The validation will be fired when the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.savechanges(v=vs.103).aspx" target="_blank"&gt;SaveChanges&lt;/a&gt; method is called and the errors will be encapsulated in a &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationexception.aspx" target="_blank"&gt;ValidationException&lt;/a&gt;:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     ctx.SaveChanges();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (ValidationException ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//see content of ex.ValidationResult.ErrorMessage&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;This code can certainly be improved – multiple validations per entity, property-based validations, etc – but I think it is good enough to illustrate my technique.&lt;/p&gt;

&lt;p align="justify"&gt;One final note: the fluent validation will only be fired if the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.infrastructure.dbcontextconfiguration.validateonsaveenabled(v=vs.103).aspx" target="_blank"&gt;ValidateOnSaveEnabled&lt;/a&gt; property is set to &lt;strong&gt;true&lt;/strong&gt;, which is the default.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10264842" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/O_2F00_RM/default.aspx">O/RM</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Entity+Framework+Code+First/default.aspx">Entity Framework Code First</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Validation/default.aspx">Validation</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Entity Framework Code First Validation</title><link>http://weblogs.asp.net/ricardoperes/archive/2013/05/09/entity-framework-code-first-validation.aspx</link><pubDate>Thu, 09 May 2013 11:40:54 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10263517</guid><dc:creator>Ricardo Peres</dc:creator><slash:comments>1</slash:comments><description>&lt;h2&gt;Introduction&lt;/h2&gt;  &lt;p align="justify"&gt;Most persistence frameworks implement some kind of custom validation of entities before they are sent to the database. By custom I mean something more than just “is not null”, “has XX characters”, etc. This typically includes individual properties as well as validation of the entity as a whole – for example, checking that a property’s value is valid when used together with another property’s value.&lt;/p&gt;  &lt;p align="justify"&gt;Entity Framework Code First is no exception. Out of the box it already offers a number of possibilities for validating entities that cover typical scenarios: validation by attributes or by a validation method. One validation left out is one based on XML, but since Code First doesn’t really use XML, it should be no surprise, and the other is fluent validation, something that really should be supported.&lt;/p&gt;  &lt;p&gt;Let’s explore each of these possibilities.&lt;/p&gt;  &lt;h2&gt;Overriding ValidateEntity&lt;/h2&gt;  &lt;p align="justify"&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/gg679505(v=vs.103).aspx" target="_blank"&gt;DbContext&lt;/a&gt; class has a virtual method called &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.shouldvalidateentity(v=vs.103).aspx" target="_blank"&gt;ShouldValidateEntity&lt;/a&gt; that is called for each entity about to be persisted – meaning, inserted or updated –, and, when it returns &lt;strong&gt;true&lt;/strong&gt; – which it does by default – will trigger a call to &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.validateentity(v=vs.103).aspx" target="_blank"&gt;ValidateEntity&lt;/a&gt;, another virtual method. In this method, we have a chance to validate our entities any way we like. An example might be, for instance, checking if the entity to be saved implements &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo.aspx" target="_blank"&gt;IDataErrorInfo&lt;/a&gt; and extract validation information from this implementation:&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;   &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;     &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; DbEntityValidationResult ValidateEntity(DbEntityEntry entityEntry, IDictionary&amp;lt;Object, Object&amp;gt; items)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     DbEntityValidationResult result = &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.ValidateEntity(entityEntry, items);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     IDataErrorInfo dei = entityEntry.Entity &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; IDataErrorInfo;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (String propertyName &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; entityEntry.CurrentValues.PropertyNames)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;         String errorMessage = dei[propertyName];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (String.IsNullOrWhiteSpace(errorMessage) == &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;             result.ValidationErrors.Add(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DbValidationError(propertyName, errorMessage));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (result);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;For the validation to occur, the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.infrastructure.dbcontextconfiguration.validateonsaveenabled(v=vs.103).aspx" target="_blank"&gt;ValidateOnSave&lt;/a&gt; property must be true, which it is by default.

  &lt;br /&gt;Don’t forget to always call the base implementation!&lt;/p&gt;

&lt;h2&gt;Applying Validation Attributes&lt;/h2&gt;

&lt;p align="justify"&gt;Another option, which also applies to ASP.NET MVC validation (see &lt;a href="http://weblogs.asp.net/ricardoperes/archive/2012/06/03/asp-net-mvc-validation-complete.aspx"&gt;http://weblogs.asp.net/ricardoperes/archive/2012/06/03/asp-net-mvc-validation-complete.aspx&lt;/a&gt;) is using validation attributes, that is, attributes that inherit from &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.aspx" target="_blank"&gt;ValidationAttribute&lt;/a&gt;. The base &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.validateentity(v=vs.103).aspx" target="_blank"&gt;ValidateEntity&lt;/a&gt; method of &lt;a href="http://msdn.microsoft.com/en-us/library/gg679505(v=vs.103).aspx" target="_blank"&gt;DbContext&lt;/a&gt; also checks for these attributes, another reason why you should always call it. Let’s see an example:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; [Serializable]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; [AttributeUsage(AttributeTargets.Property, AllowMultiple = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;, Inherited = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; PositiveAttribute : ValidationAttribute&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; ValidationResult IsValid(Object &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;, ValidationContext validationContext)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;         Int64 longValue = Convert.ToInt64(&lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (longValue &amp;lt;= 0)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ValidationResult(&lt;span style="color: #006080"&gt;&amp;quot;Value cannot be negative or zero&amp;quot;&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (ValidationResult.Success);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;You would then apply this to some property in your entity:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MyEntity&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     [Positive]&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Int64 MyAlwaysPositiveNumber { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;The “problem” with this approach is that you must include any assemblies containing these custom validation attributes together with your model. If they are on the same assembly, there’s no problem.&lt;/p&gt;

&lt;p align="justify"&gt;By the way, you can specify multiple validation attributes and you can even apply them to the whole class, not just a property.&lt;/p&gt;

&lt;h2&gt;Implementing IValidatableObject&lt;/h2&gt;

&lt;p&gt;Another option, also common to MVC, is having your entities implement &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.ivalidatableobject.aspx" target="_blank"&gt;IValidatableObject&lt;/a&gt;. This interface defines a contract for returning a collection of validation errors for an entity. Here’s a sample implementation:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Contract : IValidatableObject&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; String Name { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; DateTime StartDate { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; DateTime EndDate { get; set; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;ValidationResult&amp;gt; Validate(ValidationContext validationContext)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.StartDate &amp;gt;= &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.EndDate)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;yield&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ValidationResult(&lt;span style="color: #006080"&gt;&amp;quot;The end date is before or the same as the start date&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; String[] { &lt;span style="color: #006080"&gt;&amp;quot;StartDate&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;EndDate&amp;quot;&lt;/span&gt; }));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;h2&gt;Handling SavingChanges Event&lt;/h2&gt;

&lt;p align="justify"&gt;The “underlying” &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.aspx" target="_blank"&gt;ObjectContext&lt;/a&gt; – which, in fact, is only created if requested – exposes a &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savingchanges.aspx" target="_blank"&gt;SavingChanges&lt;/a&gt; event which is triggered whenever Entity Framework is about to send changes to the database, typically whenever the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.savechanges(v=vs.103).aspx" target="_blank"&gt;SaveChanges&lt;/a&gt; method is called. If we handle this event, we can perform our custom validation before our entities are saved, and in case something is wrong we can throw an exception to cancel the saving process:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; (ctx &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; IObjectContextAdapter).ObjectContext.SavingChanges += ObjectContext_SavingChanges;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ObjectContext_SavingChanges(Object sender, EventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     ObjectContext octx = sender &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; ObjectContext;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;     IEnumerable&amp;lt;Object&amp;gt; entities = octx.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified).Select(x =&amp;gt; x.Entity);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     &lt;span style="color: #008000"&gt;//do custom validation and throw an exception if something wrong is found&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;p align="justify"&gt;This has the arguable advantage that it decouples the validation process from the entities and the context themselves.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p align="justify"&gt;In case you are using any of these validation techniques, always surround calls to &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.savechanges(v=vs.103).aspx" target="_blank"&gt;SaveChanges&lt;/a&gt; inside a &lt;strong&gt;try…catch&lt;/strong&gt; block and look out for a &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.validation.dbentityvalidationexception(v=vs.103).aspx" target="_blank"&gt;DbEntityValidationException&lt;/a&gt; or your own exception, if you followed the &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savingchanges.aspx" target="_blank"&gt;SavingChanges&lt;/a&gt; approach. Inside &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.validation.dbentityvalidationexception(v=vs.103).aspx" target="_blank"&gt;DbEntityValidationException&lt;/a&gt; you have an &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.validation.dbentityvalidationexception.entityvalidationerrors(v=vs.103).aspx" target="_blank"&gt;EntityValidationErrors&lt;/a&gt; that contains all the details:&lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; width: 97.5%; background-color: #f4f4f4"&gt;
  &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;
    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     ctx.SaveChanges();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (DbEntityValidationException ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (DbEntityValidationResult result &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; ex.EntityValidationErrors)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #008000"&gt;//..&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p align="justify"&gt;Alternatively, you can explicitly call &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.getvalidationerrors(v=vs.103).aspx" target="_blank"&gt;GetValidationErrors&lt;/a&gt; and see the collection of errors from all sources, except, of course, &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savingchanges.aspx" target="_blank"&gt;SavingChanges&lt;/a&gt;, because the context is not actually in the process of saving changes, for all entities currently being tracked by the context.&lt;/p&gt;

&lt;p align="justify"&gt;The order by which these validation processes are applied is:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.validateentity(v=vs.103).aspx" target="_blank"&gt;ValidateEntity&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.aspx" target="_blank"&gt;ValidationAttribute&lt;/a&gt; (from base &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.validateentity(v=vs.103).aspx" target="_blank"&gt;ValidateEntity&lt;/a&gt;)&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.ivalidatableobject.aspx" target="_blank"&gt;IValidatableObject&lt;/a&gt; (from base &lt;a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext.validateentity(v=vs.103).aspx" target="_blank"&gt;ValidateEntity&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.savingchanges.aspx" target="_blank"&gt;SavingChanges&lt;/a&gt; (only if no errors are found)

    &lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;











&lt;p align="justify"&gt;Pick the one that better suits your needs!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10263517" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/O_2F00_RM/default.aspx">O/RM</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Entity+Framework/default.aspx">Entity Framework</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Entity+Framework+Code+First/default.aspx">Entity Framework Code First</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Validation/default.aspx">Validation</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Blogs Portugueses Sobre SharePoint</title><link>http://weblogs.asp.net/ricardoperes/archive/2013/05/09/blogs-portugueses-sobre-sharepoint.aspx</link><pubDate>Thu, 09 May 2013 10:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10263293</guid><dc:creator>Ricardo Peres</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;This post is in portuguese only, sorry!&lt;/p&gt;  &lt;p align="justify"&gt;A partir de um comentário no &lt;a href="http://www.linkedin.com" target="_blank"&gt;LinkedIn&lt;/a&gt;, no grupo da &lt;a href="http://www.sharepointpt.org/" target="_blank"&gt;Comunidade Portuguesa de SharePoint&lt;/a&gt; (&lt;a title="http://www.linkedin.com/groups?home=&amp;amp;gid=996587&amp;amp;trk=anet_ug_hm" href="http://www.linkedin.com/groups?home=&amp;amp;gid=996587&amp;amp;trk=anet_ug_hm"&gt;http://www.linkedin.com/groups?home=&amp;amp;gid=996587&amp;amp;trk=anet_ug_hm&lt;/a&gt;) foi começada uma lista dos blogs de autores portugueses e brasileiros sobre SharePoint, ainda que não exclusivamente. Vou publicar essa lista aqui, e tentarei mantê-la actualizada.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Comunidade Portuguesa de SharePoint - &lt;a href="http://www.sharepointpt.org/"&gt;http://www.sharepointpt.org/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Tech Talk PT - &lt;a href="http://techtalkpt.wordpress.com/"&gt;http://techtalkpt.wordpress.com/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;My time break for SharePoint - &lt;a href="http://aaclage.blogspot.pt/"&gt;http://aaclage.blogspot.pt/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Stepping stones for crossing technological ponds - &lt;a href="http://mystepstones.wordpress.com/"&gt;http://mystepstones.wordpress.com/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Raquel Aline kb - &lt;a href="http://raquelalineblog.wordpress.com/"&gt;http://raquelalineblog.wordpress.com/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;EPM+ - &lt;a href="http://blogs.technet.com/b/epmmais/"&gt;http://blogs.technet.com/b/epmmais/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Demétrio Silva – Sql Server - &lt;a href="http://demetriosilva.wordpress.com/"&gt;http://demetriosilva.wordpress.com/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Ricardo Calejo - &lt;a href="http://ricardocalejo.livethoughts.net/"&gt;http://ricardocalejo.livethoughts.net/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Development With A Dot - &lt;a href="http://weblogs.asp.net/ricardoperes/"&gt;http://weblogs.asp.net/ricardoperes/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;ponto de partilha - &lt;a href="http://pontodepartilha.blogspot.pt/"&gt;http://pontodepartilha.blogspot.pt/&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;
&lt;li&gt;&lt;div align="justify"&gt;ShareM&amp;iacute;dia - &lt;a href="http://crimac.net/sharemidia/"&gt;http://crimac.net/sharemidia/&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li&gt;&lt;div align="justify"&gt;ftduarte.blogspot.com - &lt;a href="http://ftduarte.blogspot.pt/"&gt;http://ftduarte.blogspot.pt/&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li&gt;&lt;div align="justify"&gt;Andr&amp;eacute; Vala - &lt;a href="http://blogit.create.pt/blogs/andrevala/"&gt;http://blogit.create.pt/blogs/andrevala/&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li&gt;&lt;div align="justify"&gt;Miguel Isidoro  - &lt;a href="http://blogit.create.pt/blogs/miguelisidoro/"&gt;http://blogit.create.pt/blogs/miguelisidoro/&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;


 &lt;/ul&gt;  &lt;p align="justify"&gt;Se conhecerem mais, por favor, comuniquem-mos!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10263293" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Portugal/default.aspx">Portugal</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Portuguese/default.aspx">Portuguese</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Web/default.aspx">Web</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/.NET/default.aspx">.NET</category></item><item><title>System.InvalidOperationException: jsdebug Web Service method name is not valid</title><link>http://weblogs.asp.net/jhallal/archive/2013/05/08/system-invalidoperationexception-jsdebug-web-service-method-name-is-not-valid.aspx</link><pubDate>Tue, 07 May 2013 20:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10257560</guid><dc:creator>jhallal</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;If you are getting a 'web service undefined' error when calling a web service from Javascript which is defined inside the ScriptManager tag like so:
&lt;/p&gt;&lt;p&gt;&amp;lt;asp:ScriptManager ID="ScriptManager1" runat="server"&amp;gt;&lt;br&gt;&amp;lt;Services&amp;gt;&lt;br&gt;&amp;lt;asp:ServiceReference Path="~/Services/WebService.asmx" InlineScript="True" /&amp;gt;&lt;br&gt;&amp;lt;/Services&amp;gt;&lt;br&gt;&amp;lt;/asp:ScriptManager&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Actual Error:
&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;System.InvalidOperationException: jsdebug Web Service method name is not valid.
   &lt;/p&gt;

&lt;p&gt;at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   &lt;/p&gt;

&lt;p&gt;at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Solution:&lt;/u&gt;&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;To resolve this issue, run the following command line:
&lt;/p&gt;&lt;p&gt;C:\Windows\Microsoft.NET\Framework64\v4.0.30319&amp;gt;aspnet_regiis -i&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10257560" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/jhallal/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/jhallal/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/jhallal/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Using the Enterprise Library 6 Configuration Console with Visual Studio 2012</title><link>http://weblogs.asp.net/ricardoperes/archive/2013/05/07/using-the-enterprise-library-6-configuration-console-with-visual-studio-2012.aspx</link><pubDate>Tue, 07 May 2013 16:36:06 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:10257036</guid><dc:creator>Ricardo Peres</dc:creator><slash:comments>2</slash:comments><description>&lt;p align="justify"&gt;You will have to download and run the Configuration Console from &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=38789"&gt;http://www.microsoft.com/en-us/download/details.aspx?id=38789&lt;/a&gt;, there is no NuGet package for it. After that, you will get a context menu for each project on the solution for editing the configuration:&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://weblogs.asp.net/blogs/ricardoperes/image_59552BC2.png"&gt;&lt;img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://weblogs.asp.net/blogs/ricardoperes/image_thumb_6D021556.png" width="426" height="462" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=10257036" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Enterprise+Library/default.aspx">Enterprise Library</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Enterprise+Library+6/default.aspx">Enterprise Library 6</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Tools/default.aspx">Tools</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/Visual+Studio+2012/default.aspx">Visual Studio 2012</category><category domain="http://weblogs.asp.net/ricardoperes/archive/tags/.NET+4.5/default.aspx">.NET 4.5</category></item></channel></rss>