<?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>Sean McAlinden's Blog</title><link>http://weblogs.asp.net/seanmcalinden/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Windows Phone 7 Database Rapid Repository V2.0 Caching</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-caching.aspx</link><pubDate>Sun, 19 Dec 2010 00:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663905</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>0</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663905</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-caching.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx" title="Rapid Repository Release Overview" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx"&gt;Release Overview&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx" title="Rapid Repository - Creating and saving entities" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx"&gt;Creating and saving entities&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx" title="Rapid Repository Create Read Update and Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx"&gt;Create, read, update and delete operations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx" title="Rapid Repository Querying with Views and Filters" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx"&gt;Querying with views and filters&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Caching &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx" title="Rapid Repository File Helper" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx"&gt;File Helper&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx" title="Rapid Repository Examining Operation Requests" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx"&gt;Examining Operation Requests&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;All entities used at runtime are put into a cache by default.&lt;/p&gt;  &lt;p&gt;If you are likely to be getting all of the entities out of the database each time the application runs you can eager load the cache for much improved performance.&lt;/p&gt;  &lt;p&gt;The eager load runs on a separate thread so as not to affect the application page rendering.&lt;/p&gt;  &lt;p&gt;You call eager load for each entity type at application start up or in the main page constructor.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1cd44f05-c207-4371-be16-ccfb14e3802a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Eager Load&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;EntityCache&lt;/span&gt;.EagerLoad&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;If you need to turn off caching, you can set NoCache for each entity type you wish to be excluded at start up.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f006d06-d745-4aa8-9dfe-e8a48cb8217c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;No Cache&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;EntityCache&lt;/span&gt;.NoCache&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;If you are eager loading to perform queries against the entities within the database faster, consider using Views and Filters instead as this will be much quicker that loading and querying the full list of entities.&lt;/p&gt;  &lt;p&gt;I hope you find this useful.&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663905" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows Phone 7 Database Rapid Repository V2.0 File Helper</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-file-helper.aspx</link><pubDate>Sun, 19 Dec 2010 00:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663906</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>0</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663906</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-file-helper.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx" title="Rapid Repository Release Overview" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx"&gt;Release Overview&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx" title="Rapid Repository - Creating and saving entities" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx"&gt;Creating and saving entities&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx" title="Rapid Repository Create Read Update and Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx"&gt;Create, read, update and delete operations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx" title="Rapid Repository Querying with Views and Filters" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx"&gt;Querying with views and filters&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx" title="Rapid Repository Caching" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx"&gt;Caching&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;File Helper &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx" title="Rapid Repository Examining Operation Requests" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx"&gt;Examining Operation Requests&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I have added some methods for saving, retrieving and deleting files which are not entities.&lt;/p&gt;  &lt;p&gt;If you have a large amount of data such as the byte array of an image, storing the byte array directly in the entity could cause a significant performance problem as converting the byte[] to json can take quite a long time on a phone.&lt;/p&gt;  &lt;p&gt;A better solution would be to store the byte array as a separate file and just hold a pointer to the file on the entity.&lt;/p&gt;  &lt;p&gt;For example:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dd1b7dbb-d25d-40af-b2d0-e0f8fd8fd1be" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;User Profile&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IRapidEntity&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; UserName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; Photo { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Using the above class, you could store a link to an image stored as a byte array string within the file system.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:79bfc2c7-e148-4f31-9293-ba82e8ac4034" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Save User Profile&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; SavePhoto(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; userName, &lt;span style="color: rgb(43, 145, 175);"&gt;Byte&lt;/span&gt;[] photo)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 128, 0);"&gt;// convert the byte array to a string.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; photoString = &lt;span style="color: rgb(43, 145, 175);"&gt;Encoding&lt;/span&gt;.UTF8.GetString(photo, 0, photo.Length);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt; profile = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;profile.UserName = userName;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;profile.Photo = RapidRepository.&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Save(photoString);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Add(profile);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;You can load the file back using the value stored in the entity.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:085ba171-3adc-48bd-b6ee-634b777e5020" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Load Photo&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;byte&lt;/span&gt;[] LoadPhoto(&lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt; userProfile)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; photoString = RapidRepository.&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Load(userProfile.Photo);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Encoding&lt;/span&gt;.UTF8.GetBytes(photoString);&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;You can also delete the file using the same Guid value.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d4bc1d93-6770-4fb5-bd3c-958e21de0858" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Delete Photo&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DeletePhoto(&lt;span style="color: rgb(43, 145, 175);"&gt;Profile&lt;/span&gt; userProfile)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RapidRepository.&lt;span style="color: rgb(43, 145, 175);"&gt;File&lt;/span&gt;.Delete(userProfile.Photo);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;I hope you find these helper methods useful.&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663906" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows Phone 7 Database Rapid Repository V2.0 Examining Operation Requests</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-examining-operation-requests.aspx</link><pubDate>Sun, 19 Dec 2010 00:16:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663907</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>1</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663907</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-examining-operation-requests.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx" title="Rapid Repository Release Overview" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx"&gt;Release Overview&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx" title="Rapid Repository - Creating and saving entities" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx"&gt;Creating and saving entities&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx" title="Rapid Repository Create Read Update and Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx"&gt;Create, read, update and delete operations&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx" title="Rapid Repository Querying with Views and Filters" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx"&gt;Querying with views and filters&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx" title="Rapid Repository Caching" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx"&gt;Caching&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx" title="Rapid Repository File Helper" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx"&gt;File Helper&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Examining Operation Requests &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;If you need to examine the pending operation requests or even remove pending requests before calling SaveChanges() you can access them through the following property:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5149f0b8-9987-4788-a7aa-9999a9726f4b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Examine Operation Requests&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; ExamineOperationRequests()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequest&lt;/span&gt;&amp;gt; requests = &lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.OperationRequests;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;If you need to delete a request or all off the requests you can use the following methods:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f303848e-f357-4c94-801a-2f355db06877" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Operation Request Methods&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); max-height: 300px; overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; ExamineOperationRequests()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequest&lt;/span&gt;&amp;gt; requests = &lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.OperationRequests;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.DeleteOperationRequest(requests.First());&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.DeleteAllOperationRequests();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;The operation request class has the following properties you can use for examination:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2eab7593-8fc7-477f-a0ed-95b52edc35cf" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Operation Requests Properties&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); max-height: 300px; overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the entity id.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The entity id.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; EntityId { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the entity.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; Entity { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the type of the entity.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The type of the entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Type&lt;/span&gt; EntityType { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the type of the operation.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The type of the operation.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt; OperationRequestType { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;Although I don’t imagine this will be used often, it’s a feature that is there just in case, i imagine it will mostly be used in cases where compensation for transactions is required.&lt;/p&gt;  &lt;p&gt;In the next version of Rapid Repository, there will be transactional support which should further remove the need for this feature, it will stay in though.&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663907" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows Phone 7 Database Rapid Repository V2.0 Create Read Update and Delete</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-create-read-update-and-delete.aspx</link><pubDate>Sun, 19 Dec 2010 00:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663903</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>3</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663903</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-create-read-update-and-delete.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx" title="Rapid Repository Release Overview" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx"&gt;Release Overview&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx" title="Rapid Repository - Creating and saving entities" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx"&gt;Creating and saving entities&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Create, read, update and delete operations &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx" title="Rapid Repository Querying with Views and Filters" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx"&gt;Querying with views and filters&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx" title="Rapid Repository Caching" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx"&gt;Caching&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx" title="Rapid Repository File Helper" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx"&gt;File Helper&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx" title="Rapid Repository Examining Operation Requests" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx"&gt;Examining Operation Requests&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The Windows 7 phone database Rapid Repository makes create, read, update and delete functionality extremely simple.&lt;/p&gt;  &lt;p&gt;The following examples will show how to perform these operations including an extra helper method called Exists.&lt;/p&gt;  &lt;p&gt;The following entity classes will be used throughout the examples.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e41335d9-a0ed-46e1-a470-3393f16ad8dc" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Player&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IRapidEntity&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; Id { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; FirstName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; LastName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt; Scores { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Player()&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Scores = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6c5db730-ee09-4352-a9ac-04558a4c550a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;GameScore&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt; Score { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt; Date { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; } &lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Create&lt;/h2&gt;  &lt;p&gt;As seen in my previous post, a create is performed by simply calling Add on the repository and saving the changes.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fb092229-955e-41fa-98b1-340974736bfd" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Save Player&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); max-height: 300px; overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; SavePlayer()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; newPlayer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; { FirstName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Sean"&lt;/span&gt;, LastName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Mcalinden"&lt;/span&gt;, Scores = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt;() };&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPlayer.Scores.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt; { Score = 123, Date = &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now });&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Add(newPlayer);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Update&lt;/h2&gt;  &lt;p&gt;An entity is updated by simply passing the entity to the update method on the repository and saving the changes.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d1b1b073-6318-4f31-aecc-7b30eb03f32d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Update Player&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Update(&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; player)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;player.Scores.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt; { Score = 111, Date = &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now });&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Update(player);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Delete&lt;/h2&gt;  &lt;p&gt;Delete operations can be achieved by either passing the Id of the entity or by passing in the entity itself.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5bf27298-238b-4592-a1bb-b63df8503cfb" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Delete&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Delete(&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; Id)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Delete(Id);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Delete(&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; player)&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Delete(player);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Exists&lt;/h2&gt;  &lt;p&gt;The following shows an example of how to check whether an entity exists before performing an action.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:77c5099f-0042-4863-9e93-38f293e92a85" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Exists&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Exists(&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; id)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(repository.Exists(id))&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 128, 0);"&gt;// do something&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;GetById&lt;/h2&gt;  &lt;p&gt;The following shows how to retrieve an entity by it’s Id.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4a3a9547-2639-4977-8779-c8387b23b2b9" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;GetById&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; GetById(&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; id)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; entity = repository.GetById(id);&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;GetAll&lt;/h2&gt;  &lt;p&gt;The following shows how to retrieve all entities of a given type, this returns a list which you can filter using linq or lambda.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a8e2dead-8785-4e8d-8e8e-9f16fb74ee0c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;GetAll&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; GetAll()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; players = repository.GetAll();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8838feb0-8a3b-408d-b5f9-5d5451cc2626" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Linq &amp;amp; Lambda&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; GetAll()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; lambda = repository.GetAll()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where(x =&amp;gt; x.LastName == &lt;span style="color: rgb(163, 21, 21);"&gt;"McAlinden"&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; linq = &lt;span style="color: rgb(0, 0, 255);"&gt;from&lt;/span&gt; p &lt;span style="color: rgb(0, 0, 255);"&gt;in&lt;/span&gt; repository.GetAll()&lt;/li&gt; &lt;li&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;where&lt;/span&gt; p.LastName == &lt;span style="color: rgb(163, 21, 21);"&gt;"McAlinden"&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;select&lt;/span&gt; p;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;This covers all of the main repository methods.&lt;/p&gt;  &lt;p&gt;The next post will show a much better way to query the database using Views and Filters.&lt;/p&gt;  &lt;p&gt;I Hope this is useful.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663903" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows Phone 7 Database Rapid Repository V2.0 Querying with Views and Filters</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-querying-with-views-and-filters.aspx</link><pubDate>Sun, 19 Dec 2010 00:15:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663904</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>0</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663904</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-querying-with-views-and-filters.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx" title="Rapid Repository Release Overview" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx"&gt;Release Overview&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx" title="Rapid Repository - Creating and saving entities" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx"&gt;Creating and saving entities&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx" title="Rapid Repository Create Read Update and Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx"&gt;Create, read, update and delete operations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Querying with views and filters &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx" title="Rapid Repository Caching" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx"&gt;Caching&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx" title="Rapid Repository File Helper" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx"&gt;File Helper&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx" title="Rapid Repository Examining Operation Requests" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx"&gt;Examining Operation Requests&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Views and Filters are the main features driving Rapid Repository V2.0.&lt;/p&gt;  &lt;p&gt;The purpose of Views and Filters are to greatly improve performance when querying the database.&lt;/p&gt;  &lt;p&gt;The following examples will show how to create and use views and filters.&lt;/p&gt;  &lt;p&gt;For the examples we are going to be using the following entities:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72bc2a78-9b8c-4878-8f97-29bffa8397c0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Customer&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IRapidEntity&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; Id { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Title {&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;;&lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; FirstName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; LastName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; PhoneNumber { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; MobileNumber { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Address&lt;/span&gt; Address { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Address&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; HouseNumber { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; PostCode { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;What are Views and why use them?&lt;/h2&gt;  &lt;p&gt;Views are simply a subset of an entity, lets say you are designing a page that lists the last name and postal code of each customer, it would be really inefficient to load all of the entity data just to display this limited amount of data (especially if you have a lot of data).&lt;/p&gt;  &lt;p&gt;In this scenario, the page would be better served with a flattened list of classes containing just the information it requires for the page, this is called a View Model.&lt;/p&gt;  &lt;p&gt;For the rest of the examples we are going to create and use the following View Model:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b6b41d4a-2316-415a-aad0-df5d107b4b82" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Customer View Model&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IRapidView&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; Id { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; LastName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; PostCode { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You will notice that along with the data required for displaying on the page, there is also an Id property enforced by the IRapidView interface.&lt;/p&gt;  &lt;p&gt;This Id is set to the Id of the actual entity when the view is created, this allows GetById to be called using the View Model Id and have the actual entity returned.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Creating the View&lt;/h2&gt;  &lt;p&gt;Creating the view is really simple although it does require the use of lambda.&lt;/p&gt;  &lt;p&gt;During application start up or in the MainPage constructor, you need to set up the mapping for the view.&lt;/p&gt;  &lt;p&gt;This is achieved by mapping the View Model properties to it’s corresponding entity property.&lt;/p&gt;  &lt;p&gt;The following example creates the mapping for the CustomerViewModel:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:65faf763-6627-4060-aa3d-9ae5b64e36dc" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Setup View Mapping&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt; { LastName = x.LastName, PostCode = x.Address.PostCode });&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;As you can see, in this case a mapping has been created for the CustomerViewModel in the main page constructor.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Querying the View&lt;/h2&gt;  &lt;p&gt;Once the mapping is setup, you can query the view data by using the Query method on the repository.&lt;/p&gt;  &lt;p&gt;The following example shows the View being queried and filtered to only retrieve customers from south west London.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:69436fee-18a4-4292-a5c2-f85a0565d77f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Querying the View&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DisplayCustomersInSouthWestLondon()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt; londonCustomers = repository.Query&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where(x =&amp;gt; x.PostCode.StartsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;"SW"&lt;/span&gt;)).ToList();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myListBox.ItemSource = londonCustomers;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;First thing to notice is the View type is passed as a generic argument, this is because an entity could have many different views for different pages.&lt;/p&gt;  &lt;p&gt;As previously mentioned, you can get the actual entity from the database using the Id of a View.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f483def5-e6c1-469e-8d01-22ee842a162a" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Get Customer Entity&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DisplayCustomersInSouthWestLondon()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt; londonCustomers = repository.Query&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where(x =&amp;gt; x.PostCode.StartsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;"SW"&lt;/span&gt;)).ToList();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt; firstCustomerInList = repository.GetById(londonCustomers[0].Id);&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Filtering the View&lt;/h2&gt;  &lt;p&gt;In the example so far, we are retrieving the View and then filtering it further by postal code, if the page is actually only ever going to display customers from London we could pre filter the view.&lt;/p&gt;  &lt;p&gt;This further aids performance and reduces the code we have to write when querying the database.&lt;/p&gt;  &lt;p&gt;Pre-filtering is achieved using the AddFilter method when the View mapping is set up.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e9bd344b-c194-4d46-9161-b0aa632857f8" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Adding a filter.&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt; { LastName = x.LastName, PostCode = x.Address.PostCode })&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.AddFilter(x =&amp;gt; x.PostCode.StartsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;"SW"&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;As you can see, the same filter we were achieving using lambda is now a fixed filter for the view, this means that only the data that is actually required for this View is saved.&lt;/p&gt;  &lt;p&gt;You can add multiple filters using the fluent syntax.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:68887244-b6fe-40c5-8cc3-fef75085b03b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Multiple Filters&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt; { LastName = x.LastName, PostCode = x.Address.PostCode })&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.AddFilter(x =&amp;gt; x.PostCode.StartsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;"SW"&lt;/span&gt;))&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.AddFilter(x =&amp;gt; x.LastName.Contains(&lt;span style="color: rgb(163, 21, 21);"&gt;"Mc"&lt;/span&gt;));&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Synchronising The View (Used when upgrading)&lt;/h2&gt;  &lt;p&gt;If you are upgrading from V1.0 and already have saved entities that you will now be using a View Model for displaying data, you will need to synchronise the data in the database.&lt;/p&gt;  &lt;p&gt;This can be done as a one-off during your upgrade script or even better, if you can afford the small overhead during application start-up do it then so it re-synchronises each time the user starts the app (it shouldn’t need to be done, this is only for the more pessimistic coder).&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:721c1d2c-247d-4951-9bb0-8e93ec944faa" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Synchronising the View&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt; { LastName = x.LastName, PostCode = x.Address.PostCode })&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.AddFilter(x =&amp;gt; x.PostCode.StartsWith(&lt;span style="color: rgb(163, 21, 21);"&gt;"SW"&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Customer&lt;/span&gt;&amp;gt;.SynchroniseView&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;CustomerViewModel&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Make sure you’ve registered the view mapping before calling synchronise.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;Hopefully you agree that this is a really powerful addition to the repository and will greatly improve performance when querying the database.&lt;/p&gt;  &lt;p&gt;I hope you find this useful.&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663904" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows Phone 7 Database Rapid Repository V2.0 Creating and Saving Entities</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-creating-and-saving-entities.aspx</link><pubDate>Sun, 19 Dec 2010 00:14:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663902</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>2</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663902</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-creating-and-saving-entities.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx" title="Rapid Repository Release Overview" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Released.aspx"&gt;Release Overview&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Creating and saving entities &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx" title="Rapid Repository Create Read Update and Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx"&gt;Create, read, update and delete operations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx" title="Rapid Repository Querying with Views and Filters" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx"&gt;Querying with views and filters&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx" title="Rapid Repository Caching" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx"&gt;Caching&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx" title="Rapid Repository File Helper" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx"&gt;File Helper&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx" title="Rapid Repository Examining Operation Requests" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx"&gt;Examining Operation Requests&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;ul&gt;&lt;/ul&gt;  &lt;p&gt;Creating and saving entities to the Windows 7 Phone is really simple when using the Rapid Repository.&lt;/p&gt;  &lt;p&gt;For the following examples, my entity is called Player which among it’s properties contains a list of entities called GameScore.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:169bd26c-c7ff-40ab-8ac1-dd1f2131f390" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Player&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;IRapidEntity&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; Id { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; FirstName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; LastName { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt; Scores { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Player()&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Scores = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f7477dd-0fed-46ca-bc4c-db8e742feddf" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;GameScore&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;double&lt;/span&gt; Score { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt; Date { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; } &lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;As you can see, the Player class is the root entity or root aggregate, you will notice that it implement the IRapidEntity interface.&lt;/p&gt;  &lt;p&gt;This interface enforces the implementation of a Guid Id property.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Simple Example&lt;/h2&gt;  &lt;p&gt;The following example shows how to save an entity to the database.&lt;/p&gt;  &lt;p&gt;There is no setup at all, the following code is all you need to save a valid entity.&lt;/p&gt;  &lt;h2&gt;   &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cc9ba59d-45ae-4422-b815-19e16331e757" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Saving a Player instance&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; SavePlayer()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; newPlayer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; { FirstName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Sean"&lt;/span&gt;, LastName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Mcalinden"&lt;/span&gt;, Scores = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt;() };&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPlayer.Scores.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt; { Score = 123, Date = &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now });&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Add(newPlayer);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/h2&gt;  &lt;p&gt;As you can see, once the player is created, a repository is created, the player is passed to the Add method and finally SaveChanges() is called on the current context.&lt;/p&gt;  &lt;p&gt;The newPlayer instance passed in will now have it’s Id property populated (Do not change this Id).&lt;/p&gt;  &lt;p&gt;*Note*&lt;/p&gt;  &lt;p&gt;The reason you call SaveChanges() is because when Add is called on the repository, it is just creating a request to save the entity, it is not actually saved until SaveChanges() is called. &lt;/p&gt;  &lt;h2&gt;&amp;nbsp;&lt;/h2&gt;  &lt;h2&gt;Simple Example with Pre-Populated Id&lt;/h2&gt;  &lt;p&gt;Similar to the previous example, if for any reason you need to create your own Id rather than have the framework create it, you simple set the Id property before SaveChanges() is called on the context.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e1bff228-aa1a-4ed3-aeac-fa86229abfbc" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Save with pre-populated Id&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; SavePlayerWithPrePopulatedId()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; id = &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt;.NewGuid();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; newPlayer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; { Id = id, FirstName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Sean"&lt;/span&gt;, LastName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Mcalinden"&lt;/span&gt;, Scores = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt;() };&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPlayer.Scores.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt; { Score = 123, Date = &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now });&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Add(newPlayer);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Derived Repository&lt;/h2&gt;  &lt;p&gt;If you want to add extra functionality such as logging or you want to hide away the call to Savechanges() on the context, you can derive from RapidRepository&amp;lt;&amp;gt;, all the relevant methods can be overridden.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:217212db-d714-4b55-8f50-77bcab5b7629" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Player Repository&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PlayerRepository&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt;&amp;gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; Add(&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; entity)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.Add(entity);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; entity;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; Update(&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; entity)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.Update(entity);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; entity;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Delete(&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; entity)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.Delete(entity);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Delete(System.&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; id)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.Delete(id);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.SaveChanges();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Now the above SavePlayer() method looks like the following:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b161def8-5549-44d2-a621-9915fff72cfa" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Save player&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; SavePlayer()&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; newPlayer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Player&lt;/span&gt; { FirstName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Sean"&lt;/span&gt;, LastName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Mcalinden"&lt;/span&gt;, Scores = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt;&amp;gt;() };&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newPlayer.Scores.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GameScore&lt;/span&gt; { Score = 123, Date = &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now });&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(43, 145, 175);"&gt;PlayerRepository&lt;/span&gt; repository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PlayerRepository&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;repository.Add(newPlayer);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;That’s about it for saving entities, the next post will cover all of the Create, Read, Update and Delete functionality.&lt;/p&gt;  &lt;p&gt;I hope you find this useful.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663902" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows Phone 7 Database Rapid Repository V2.0 Released</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-released.aspx</link><pubDate>Sun, 19 Dec 2010 00:13:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7663901</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>10</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7663901</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/windows-7-phone-database-rapid-repository-v2-0-released.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#000000"&gt;Rapid Repository is a Windows Phone 7 Database and Silverlight Isolated Storage Database.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Rapid Repository requires no setup and the API has been designed to be easy to use and discoverable, you will be saving, updating, deleting and querying your complex entities within minutes.&lt;/p&gt;  &lt;p&gt;There is no major learning curve, you will literally have a near full understanding of most of the repository within minutes of downloading and referencing the library.&lt;/p&gt;  &lt;p&gt;The more advanced features such as querying with views and filters are still very easy to use and the tutorials provided will have you using them within minutes.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4" color="#646b86"&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="Rapid Repository - Windows 7 Phone Database" mce_href="http://rapidrepository.codeplex.com/"&gt;Download Rapid Repository from Microsoft Codeplex&lt;/a&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;h2&gt;&lt;b&gt;&lt;font color="#8064a2"&gt;Blog Tutorials&lt;/font&gt;&lt;/b&gt;&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;Release Overview &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx" title="Rapid Repository - Creating and saving entities" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Creating-and-Saving-Entities.aspx"&gt;Creating and saving entities&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx" title="Rapid Repository Create Read Update and Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Create-Read-Update-and-Delete.aspx"&gt;Create, read, update and delete operations&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx" title="Rapid Repository Querying with Views and Filters" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Querying-with-Views-and-Filters.aspx"&gt;Querying with views and filters&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx" title="Rapid Repository Caching" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Caching.aspx"&gt;Caching&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx" title="Rapid Repository File Helper" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-File-Helper.aspx"&gt;File Helper&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx" title="Rapid Repository Examining Operation Requests" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/19/Windows-7-Phone-Database-Rapid-Repository-V2-0-Examining-Operation-Requests.aspx"&gt;Examining Operation Requests&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I will be adding some samples and video tutorials soon.&lt;/p&gt;  &lt;h1&gt;V2.0 Features&lt;/h1&gt;  &lt;p&gt;This is a full list of features within Rapid Repository V2.0&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Numerous methods for performing Create, Read, Update and Delete operations      &lt;ul&gt;       &lt;li&gt;Add &lt;/li&gt;        &lt;li&gt;Update &lt;/li&gt;        &lt;li&gt;Delete &lt;/li&gt;        &lt;li&gt;Exists &lt;/li&gt;        &lt;li&gt;GetById &lt;/li&gt;        &lt;li&gt;GetAll &lt;/li&gt;        &lt;li&gt;Query &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Views &amp;amp; Filters      &lt;ul&gt;       &lt;li&gt;A view is a subset of an entity which can be implemented to greatly improve querying speed and performance &lt;/li&gt;        &lt;li&gt;Filters are Where Conditions placed on the view to further filter the data &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Rapid Context      &lt;ul&gt;       &lt;li&gt;The context is mainly used for performing any operations request by the repository &lt;/li&gt;        &lt;li&gt;It also allows access to all operation requests, this enables the examination and updating/deleting of any pending changes if required in more complex scenarios &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Entity Cache      &lt;ul&gt;       &lt;li&gt;Entities are cached locally by default for improved performance, there are methods available for eager loading the cache at application start up and also for turning off caching on a per entity basis &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;File Access Helper      &lt;ul&gt;       &lt;li&gt;RapidRepository.File contains helper methods for storing file that are not entities such as an image byte array &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;Breaking Changes&lt;/h2&gt;  &lt;p&gt;RapidContext has moved from namespace RapidRepository.Context to the root namespace RapidRepository. This was done as the context should be a top level class.&lt;/p&gt;  &lt;p&gt;A new OperationRequests property has been added to the RapidContext – this is now the way to access any pending requests.&lt;/p&gt;  &lt;h2&gt;Bug Fixes&lt;/h2&gt;  &lt;p&gt;There have been numerous improvements from V1.0, the main bug that has been fixed was a caching bug that sometimes caused the GetAll method to not load all entities.&lt;/p&gt;  &lt;h2&gt;Technical Details&lt;/h2&gt;  &lt;p&gt;The full source code and tests can be downloaded from or browsed on the Microsoft Codeplex site &lt;a href="http://rapidrepository.codeplex.com/" title="http://rapidrepository.codeplex.com/" mce_href="http://rapidrepository.codeplex.com/"&gt;http://rapidrepository.codeplex.com/&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;As an overview, the Rapid Repository is a document database which serialises and deserialises entities into Json and saves the json as text files within the Windows 7 Phone Isolated Storage.&lt;/p&gt;  &lt;p&gt;Each saved entity has it’s own json file with a globally unique identifier (GUID) filename.&lt;/p&gt;  &lt;p&gt;Views are stored slightly differently, instead of have a file per row, a view is stored in a single json file for the specific view type. An entity can have many different views.&lt;/p&gt;  &lt;p&gt;Caching is turned on for each entity type by default, this can be turned off if required. The cache stores an in-memory representation of all entities used during the application session, this enables better performance when re-using the entities within an application session.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;I’m really happy with the improvements in V2.0 and I especially think the Views and Filters feature will be really useful as it will greatly improve the speed of querying the data within the repository.&lt;/p&gt;  &lt;p&gt;I hope you like it and would be really grateful for any feedback.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663901" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows 7 Phone Database Rapid Repository – V2.0 Beta Released</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/07/windows-7-phone-database-rapid-repository-v2-0-beta-released.aspx</link><pubDate>Tue, 07 Dec 2010 23:20:13 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7657921</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>4</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7657921</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/07/windows-7-phone-database-rapid-repository-v2-0-beta-released.aspx#comments</comments><description>&lt;p&gt;Hi All,&lt;/p&gt;  &lt;p&gt;A V2.0 beta has been released for the Windows 7 Phone database Rapid Repository, this can be downloaded at the following: &lt;a title="http://rapidrepository.codeplex.com/" href="http://rapidrepository.codeplex.com/"&gt;http://rapidrepository.codeplex.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Along with the new &lt;a title="Rapid Repository Querying with Views and Filters" href="http://weblogs.asp.net/seanmcalinden/archive/2010/12/05/windows-7-phone-database-querying-with-views-and-filters.aspx"&gt;View feature&lt;/a&gt; which greatly enhances querying and performance, various bugs have been fixed including a more serious bug with the caching that caused the GetAll() method to sometimes return inconsistent results (I’m a little bit embarrased by this bug).&lt;/p&gt;  &lt;p&gt;If you are currently using V1.0 in development, I would recommend swapping in the beta immediately.&lt;/p&gt;  &lt;p&gt;A full release will be available very shortly, I just need a few more days of testing and some input from other users/testers.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;*Breaking Changes*&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The only real change is the RapidContext has moved under the main RapidRepository namespace.&lt;/p&gt;  &lt;p&gt;Various internal methods have been actually made ‘internal’ and replaced with a more friendly API (I imagine not many users will notice this change).&lt;/p&gt;  &lt;p&gt;Hope you like it&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7657921" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Rapid Repository – Silverlight Development</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/06/rapid-repository-silverlight-development.aspx</link><pubDate>Mon, 06 Dec 2010 21:11:03 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7657109</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>0</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7657109</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/06/rapid-repository-silverlight-development.aspx#comments</comments><description>&lt;p&gt;Hi All,&lt;/p&gt;  &lt;p&gt;One of the questions I was recently asked was whether the &lt;a title="Windows 7 phone database - silverlight database rapid repository" href="http://rapidrepository.codeplex.com/"&gt;Rapid Repository&lt;/a&gt; would work for normal Silverlight development as well as for the Windows 7 Phone.&lt;/p&gt;  &lt;p&gt;I can confirm that the current code in the trunk &lt;strong&gt;&lt;u&gt;will&lt;/u&gt;&lt;/strong&gt; definitely work for both the Windows 7 Phone and normal Silverlight development.&lt;/p&gt;  &lt;p&gt;I haven’t tested V.1.0 for compatibility but V2.0 which will be released fairly soon will work absolutely fine.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7657109" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Isolated+Storage/default.aspx">Silverlight Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Silverlight+Development/default.aspx">Silverlight Development</category></item><item><title>Windows 7 Phone Database – Querying with Views and Filters</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/12/05/windows-7-phone-database-querying-with-views-and-filters.aspx</link><pubDate>Sun, 05 Dec 2010 22:30:10 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7656438</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>5</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7656438</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/12/05/windows-7-phone-database-querying-with-views-and-filters.aspx#comments</comments><description>&lt;p&gt;I’ve just added a feature to Rapid Repository to greatly improve how the Windows 7 Phone Database is queried for performance (This is in the trunk not in Release V1.0).&lt;/p&gt;  &lt;p&gt;The main concept behind it is to create a View Model class which would have only the minimum data you need for a page. &lt;/p&gt;  &lt;p&gt;This View Model is then stored and retrieved rather than the whole list of entities. &lt;/p&gt;  &lt;p&gt;Another feature of the views is that they can be pre-filtered to even further improve performance when querying.&lt;/p&gt;  &lt;p&gt;You can download the source from the Microsoft Codeplex site &lt;a title="http://rapidrepository.codeplex.com/" href="http://rapidrepository.codeplex.com/"&gt;http://rapidrepository.codeplex.com/&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff" size="5"&gt;Setting up a view&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Lets say you have an entity that stores lots of data about a game result for example:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:eb8aabf2-b7cb-4abd-b28a-ece059fc477b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;GameScore entity&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IRapidEntity&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt; Id { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; GamerId {&lt;span style="color:#0000ff"&gt;get&lt;/span&gt;;&lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;}&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Name { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Double&lt;/span&gt; Score { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Byte&lt;/span&gt;[] ThumbnailAvatar { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt; DateAdded { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;On your page you want to display a list of scores but you only want to display the score and the date added, you create a View Model for displaying just those properties.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:40b13ce2-c59f-43a2-ba42-1a40655016c4" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;GameScoreView&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IRapidView&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt; Id { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Double&lt;/span&gt; Score { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt; DateAdded { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now you have the view model, the first thing to do is set up the view at application start up.&lt;/p&gt;  &lt;p&gt;This is done using the following syntax.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:37b09a0c-7efe-4a6f-8eca-3c982f114a59" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;View Setup&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt; { DateAdded = x.DateAdded, Score = x.Score });&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;As you can see, using a little bit of lambda syntax, you put in the code for constructing a single view, this is used internally for mapping an entity to a view.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;*Note*&lt;/em&gt; you do not need to map the Id property, this is done automatically, a view model id will always be the same as it’s corresponding entity.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff" size="5"&gt;Adding Filters&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One of the cool features of the view is that you can add filters to limit the amount of data stored in the view, this will dramatically improve performance.&lt;/p&gt;  &lt;p&gt;You can add multiple filters using the fluent syntax if required.&lt;/p&gt;  &lt;p&gt;In this example, lets say that you will only ever show the scores for the last 10 days, you could add a filter like the following:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:77960bb3-73e7-41b0-ad0f-dd8684e7ddd0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Add single filter&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt; { DateAdded = x.DateAdded, Score = x.Score })&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        .AddFilter(x =&amp;gt; x.DateAdded &amp;gt; &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now.AddDays(-10));&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;If you wanted to further limit the data, you could also say only scores above 100:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:931ee919-a445-4dc1-9887-eac3139edb38" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Add multiple filters&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; MainPage()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;.AddView&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt;(x =&amp;gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt; { DateAdded = x.DateAdded, Score = x.Score })&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        .AddFilter(x =&amp;gt; x.DateAdded &amp;gt; &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now.AddDays(-10))&lt;/li&gt; &lt;li&gt;        .AddFilter(x =&amp;gt; x.Score &amp;gt; 100);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff" size="5"&gt;Querying the view model&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So the important part is how to query the data.&lt;/p&gt;  &lt;p&gt;This is done using the repository, there is a method called Query which accepts the type of view as a generic parameter (you can have multiple View Model types per entity type)&lt;/p&gt;  &lt;p&gt;You can either use the result of the query method directly or perform further querying on the result is required.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c19889bc-5942-4822-8ba0-f3802589e858" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Querying the View&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; DisplayScores()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt; repository = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt; scores = repository.Query&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;// display logic&lt;/span&gt;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:69e8e17d-ed73-4f34-b562-96095c3600d0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Further Filtering&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; TodaysScores()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt; repository = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt; todaysScores = repository.Query&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt;().Where(x =&amp;gt; x.DateAdded &amp;gt; &lt;span style="color:#2b91af"&gt;DateTime&lt;/span&gt;.Now.AddDays(-1)).ToList();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;// display logic&lt;/span&gt;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff" size="5"&gt;Retrieving the actual entity&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Retrieving the actual entity can be done easily by using the GetById method on the repository.&lt;/p&gt;  &lt;p&gt;Say for example you allow the user to click on a specific score to get further information, you can use the Id populated in the returned View Model GameScoreView and use it directly on the repository to retrieve the full entity.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6be86c1e-f552-46b8-aad6-1ba910035526" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Get Full Entity&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; GetFullEntity(&lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt; gameScoreViewId)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt; repository = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt; fullEntity = repository.GetById(gameScoreViewId);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    &lt;span style="color:#008000"&gt;// display logic&lt;/span&gt;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff" size="5"&gt;Synchronising The View&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you are upgrading from Rapid Repository V1.0 and are likely to have data in the repository already, you will need to perform a synchronisation to ensure the views and entities are fully in sync.&lt;/p&gt;  &lt;p&gt;You can either do this as a one off during the application upgrade or if you are a little more cautious, you could run this at each application start up.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:01560c19-bd33-473e-b4b2-93292ce54a1c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Synchronise the view&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; MyUpgradeTasks()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;RapidRepository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;GameScore&lt;/span&gt;&amp;gt;.SynchroniseView&amp;lt;&lt;span style="color:#2b91af"&gt;GameScoreView&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;It’s worth noting that in normal operation, the view keeps itself in sync with the entities so this is only really required if you are upgrading from V1.0 to V2.0 when it gets released shortly.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0000ff" size="5"&gt;Summary&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I really hope you like this feature, it will be great for performance and I believe supports good practice by promoting the use of View Models for specific pages.&lt;/p&gt;  &lt;p&gt;I’m hoping to produce a beta for this over the next few days, I just want to add some more tests and hopefully iron out any bugs.&lt;/p&gt;  &lt;p&gt;I would really appreciate any thoughts on this feature and would really love to know of any bugs you find.&lt;/p&gt;  &lt;p&gt;You can download the source from the following : &lt;a title="http://rapidrepository.codeplex.com/" href="http://rapidrepository.codeplex.com/"&gt;http://rapidrepository.codeplex.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7656438" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Windows 7 Phone – Loading from Isolated Storage</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/11/18/windows-7-phone-loading-from-isolated-storage.aspx</link><pubDate>Thu, 18 Nov 2010 22:18:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7646697</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>2</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7646697</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/11/18/windows-7-phone-loading-from-isolated-storage.aspx#comments</comments><description>&lt;p&gt;In my previous post &lt;a title="Windows 7 Phone Saving to isolated storage" href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/17/windows-7-phone-saving-to-isolated-storage.aspx"&gt;(Saving to isolated storage)&lt;/a&gt; I demonstrated a simple example of saving a serialised json file to the Windows 7 Phone isolated storage, in this post I’m going to show a simple example of retrieving a file out of isolated storage simlar to my approach in the &lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/07/windows-7-phone-database-rapid-repository-v1-released.aspx"&gt;Windows 7 phone database Rapid Repository&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Here we go…&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3ff1eaeb-f3b9-49de-a0d8-8905e570a93c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Load isolated storage file&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;LoadFileFromIsolatedStorage&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; myDirectory = &lt;span style="color:#a31515"&gt;&amp;quot;MyDirectory&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; LoadFile(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; fileName)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; store = &lt;span style="color:#2b91af"&gt;IsolatedStorageFile&lt;/span&gt;.GetUserStoreForApplication())&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; filePath = &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;{0}.json&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af"&gt;Path&lt;/span&gt;.Combine(myDirectory, fileName));&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;IsolatedStorageFileStream&lt;/span&gt; fileStream = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IsolatedStorageFileStream&lt;/span&gt;(filePath, &lt;span style="color:#2b91af"&gt;FileMode&lt;/span&gt;.Open, store))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                {&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;TextReader&lt;/span&gt; reader = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;StreamReader&lt;/span&gt;(fileStream))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    {&lt;/li&gt; &lt;li&gt;                        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; reader.ReadLine();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    }&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;IsolatedStorageException&lt;/span&gt; exception)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; exception;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;As you can see, a store variable is set to the application user store and get the file path.&lt;/p&gt;  &lt;p&gt;We then open a file stream and use a text reader to read the json file which is then returned as a string.&lt;/p&gt;  &lt;p&gt;I hope this is useful, if you would like to see a more ‘real world’ example – you can view the source of the &lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/07/windows-7-phone-database-rapid-repository-v1-released.aspx"&gt;Rapid Repository&lt;/a&gt; FileManager class &lt;a href="http://rapidrepository.codeplex.com/SourceControl/changeset/view/b6b49e80f075#RapidRepository%2fRapidRepository%2fDatabase%2fFileManager.cs"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7646697" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Windows 7 Phone – Saving to Isolated Storage</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/11/17/windows-7-phone-saving-to-isolated-storage.aspx</link><pubDate>Wed, 17 Nov 2010 14:07:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7645884</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>3</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7645884</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/11/17/windows-7-phone-saving-to-isolated-storage.aspx#comments</comments><description>&lt;p&gt;I was recently asked how to save a serialised file to the Windows 7 phone isolated storage so I thought I’d post an example, similar to how I did this within my &lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/07/windows-7-phone-database-rapid-repository-v1-released.aspx"&gt;Windows 7 phone database Rapid Repository&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In this post, I’m going to show a simple example of:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Creating a directory &lt;/li&gt;    &lt;li&gt;Building the file path &lt;/li&gt;    &lt;li&gt;Saving the file &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;To see how to load a file from isolated storage, see the following post &lt;a title="http://weblogs.asp.net/seanmcalinden/archive/2010/11/18/windows-7-phone-loading-from-isolated-storage.aspx" href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/18/windows-7-phone-loading-from-isolated-storage.aspx"&gt;http://weblogs.asp.net/seanmcalinden/archive/2010/11/18/windows-7-phone-loading-from-isolated-storage.aspx&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This post assumes that you have a serialised json file to save that is passed into the Save method along with a file name.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Here we go…&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6502d159-8cb8-4a09-969e-d2645bbf5ab4" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Save to isolated storage&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;SaveToIsolatedStorage&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; myDirectory = &lt;span style="color:#a31515"&gt;&amp;quot;MyDirectory&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Save(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; fileName, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; jsonFile)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;try&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;IsolatedStorageFile&lt;/span&gt; store = &lt;span style="color:#2b91af"&gt;IsolatedStorageFile&lt;/span&gt;.GetUserStoreForApplication())&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            {&lt;/li&gt; &lt;li&gt;                fileName = &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;{0}.json&amp;quot;&lt;/span&gt;, fileName);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; filePath = &lt;span style="color:#2b91af"&gt;Path&lt;/span&gt;.Combine(myDirectory, fileName);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!store.DirectoryExists(myDirectory))&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    store.CreateDirectory(myDirectory);&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;IsolatedStorageFileStream&lt;/span&gt; fileStream = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IsolatedStorageFileStream&lt;/span&gt;(filePath, &lt;span style="color:#2b91af"&gt;FileMode&lt;/span&gt;.Create, store))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                {&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;StreamWriter&lt;/span&gt; stream = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;StreamWriter&lt;/span&gt;(fileStream))&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    {&lt;/li&gt; &lt;li&gt;                        stream.Write(jsonFile);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                    }&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            }&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;catch&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;IsolatedStorageException&lt;/span&gt; exception)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; exception;&lt;/li&gt; &lt;li&gt;        }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;As you can see,&amp;#160; we get the user store for the application, this is then used for all our interaction with the isolated storage file system.&lt;/p&gt;  &lt;p&gt;Once we have the store, a directory called MyDirectory is created if it doesn’t already exist.&lt;/p&gt;  &lt;p&gt;Once we’re happy the directory exists we open a file stream and then use a stream writer to write the json file to isolated storage.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I hope that this is useful, if you would like to see a more ‘real world’ example – you can view the source of the &lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/07/windows-7-phone-database-rapid-repository-v1-released.aspx"&gt;Rapid Repository&lt;/a&gt; FileManager class &lt;a href="http://rapidrepository.codeplex.com/SourceControl/changeset/view/b6b49e80f075#RapidRepository%2fRapidRepository%2fDatabase%2fFileManager.cs"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7645884" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Windows 7 Phone Database Rapid Repository Exclude Entities From Cache</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/11/12/windows-7-phone-database-rapid-repository-exclude-entities-from-cache.aspx</link><pubDate>Fri, 12 Nov 2010 20:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7641468</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>5</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7641468</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/11/12/windows-7-phone-database-rapid-repository-exclude-entities-from-cache.aspx#comments</comments><description>&lt;P&gt;&lt;B&gt;Download the code and a fully working example application from &lt;/B&gt;&lt;A href="http://rapidrepository.codeplex.com/" mce_href="http://rapidrepository.codeplex.com/"&gt;&lt;B&gt;http://rapidrepository.codeplex.com/&lt;/B&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Tutorials&lt;/U&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-introduction.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-introduction.aspx"&gt;Introduction&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-set-up.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-set-up.aspx"&gt;Set up the Rapid Repository&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-create-read-update-and-delete.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-create-read-update-and-delete.aspx"&gt;Create, Read, Update and Delete&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-eager-loading.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-eager-loading.aspx"&gt;Eager Loading&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A title="Windows 7 Phone Database Rapid Repository Examining Pending Changes" href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/10/windows-7-phone-database-rapid-repository-examining-pending-changes.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/10/windows-7-phone-database-rapid-repository-examining-pending-changes.aspx"&gt;Examining Pending Changes&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;Exclude entities from the cache &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;If you are writing a memory intensive windows 7 phone application and can’t afford any extra overhead, you can turn off the default caching within Rapid Repository on an Entity basis.&lt;/P&gt;
&lt;P&gt;The best place to do this is&amp;nbsp;at the start of your application - then all you need to do is add similar to the following code for each entity type you want to exclude:&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id=scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ad056d59-f44f-4ffc-9b15-6b10abf93cc6 class=wlWriterEditableSmartContent&gt;
&lt;DIV style="BORDER-BOTTOM: #000080 1px solid; BORDER-LEFT: #000080 1px solid; FONT-FAMILY: 'Courier New', Courier, Monospace; COLOR: #000; FONT-SIZE: 10pt; BORDER-TOP: #000080 1px solid; BORDER-RIGHT: #000080 1px solid"&gt;
&lt;DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; FONT-FAMILY: Verdana, Tahoma, Arial, sans-serif; BACKGROUND: #000080; COLOR: #fff; FONT-WEIGHT: bold; PADDING-TOP: 2px"&gt;Remove Cache Example&lt;/DIV&gt;
&lt;DIV style="BACKGROUND: #ddd; OVERFLOW: auto"&gt;
&lt;OL style="PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 2em; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; BACKGROUND: #ffffff; PADDING-TOP: 0px"&gt;
&lt;LI&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; MyApplicationStartup()&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;{&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: #2b91af"&gt;EntityCache&lt;/SPAN&gt;.NoCache&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&amp;gt;();&lt;/LI&gt;
&lt;LI style="BACKGROUND: #f3f3f3"&gt;}&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;As you can see, in this example, a Customer entity is excluded from the cache.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Note: This does mean that each time you load an entity where the type is excluded from the cache, it will have the overhead of reading from the file system and deserialising,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Hope this is useful.&lt;/P&gt;
&lt;P&gt;Sean McAlinden&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7641468" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Windows 7 Phone Database Rapid Repository – Examining Pending Changes</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/11/10/windows-7-phone-database-rapid-repository-examining-pending-changes.aspx</link><pubDate>Wed, 10 Nov 2010 22:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7640028</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>3</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7640028</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/11/10/windows-7-phone-database-rapid-repository-examining-pending-changes.aspx#comments</comments><description>&lt;p&gt;&lt;font size="3" color="#9b00d3"&gt;&lt;b&gt;Download the code and a fully working example application from &lt;/b&gt;&lt;/font&gt;&lt;a href="http://rapidrepository.codeplex.com/" title="http://rapidrepository.codeplex.com/"&gt;&lt;font size="3" color="#9b00d3"&gt;&lt;b&gt;http://rapidrepository.codeplex.com/&lt;/b&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;u&gt;Tutorials&lt;/u&gt;&lt;/p&gt;&lt;ol&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-introduction.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-introduction.aspx"&gt;Introduction&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-set-up.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-set-up.aspx"&gt;Set up the Rapid Repository&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-create-read-update-and-delete.aspx" title="Windows 7 Phone Database Rapid Repository Create Read Update Delete" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-create-read-update-and-delete.aspx"&gt;Create, Read, Update and Delete&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-eager-loading.aspx" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/10/31/windows-7-phone-database-rapid-repository-eager-loading.aspx"&gt;Eager Loading&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Examining Pending Changes &lt;/li&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/12/windows-7-phone-database-rapid-repository-exclude-entities-from-cache.aspx" title="Windows 7 Phone Database Rapid Repository Exclude Entities From Cache" mce_href="http://weblogs.asp.net/seanmcalinden/archive/2010/11/12/windows-7-phone-database-rapid-repository-exclude-entities-from-cache.aspx"&gt;Exclude entities from the cache&lt;/a&gt;&lt;br&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;A possible useful feature of the &lt;a href="http://rapidrepository.codeplex.com/" title="Windows 7 Phone Database - Rapid Repository" mce_href="http://rapidrepository.codeplex.com/"&gt;RapidRepository&lt;/a&gt; is the ability to examine, add and remove pending changes.&lt;/p&gt;  &lt;p&gt;Basically, before you call SaveChanges() on the context, every action on the repository is held in the context as a pending change called an Operation Request.&lt;/p&gt;  &lt;p&gt;The OperationRequest class holds all of the properties required for saving the entity.&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:49c3e928-728d-4289-8d00-f6ff2a131bb7" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;OperationRequest&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt; RapidRepository.DbC;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; RapidRepository.Context&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Stores data required for an operation.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequest&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;#region&lt;/span&gt; Properties&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the entity id.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The entity id.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; EntityId { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the entity.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; Entity { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the type of the entity.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The type of the entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Type&lt;/span&gt; EntityType { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Gets or sets the type of the operation.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The type of the operation.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt; OperationRequestType { &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;; } &lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;#endregion&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;#region&lt;/span&gt; Constructor&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Initializes a new instance of the &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;see cref="OperationRequest"/&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; class.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;param name="entity"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;param name="entityType"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;Type of the entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;param name="operationRequestType"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;Type of the operation request.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OperationRequest(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; entity, &lt;span style="color: rgb(43, 145, 175);"&gt;Type&lt;/span&gt; entityType, &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt; operationRequestType)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;span style="color: rgb(43, 145, 175);"&gt;Contract&lt;/span&gt;.Requires(&lt;span style="color: rgb(163, 21, 21);"&gt;"entity"&lt;/span&gt;, entity != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;);&lt;/li&gt; &lt;li&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;&lt;span style="color: rgb(43, 145, 175);"&gt;Contract&lt;/span&gt;.Requires(&lt;span style="color: rgb(163, 21, 21);"&gt;"entityType"&lt;/span&gt;, entityType != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&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;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (operationRequestType != Context.&lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt;.Add)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;{&lt;/li&gt; &lt;li&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.EntityId = ((&lt;span style="color: rgb(43, 145, 175);"&gt;IRapidEntity&lt;/span&gt;)entity).Id;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Entity = entity;&lt;/li&gt; &lt;li&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.EntityType = entityType;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.OperationRequestType = operationRequestType;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Initializes a new instance of the &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;see cref="OperationRequest"/&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; class.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;param name="entityId"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;The entity id.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;param name="entityType"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;Type of the entity.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;param name="operationRequestType"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;Type of the operation request.&lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OperationRequest(&lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt; entityId, &lt;span style="color: rgb(43, 145, 175);"&gt;Type&lt;/span&gt; entityType, &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt; operationRequestType)&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li&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;&lt;span style="color: rgb(43, 145, 175);"&gt;Contract&lt;/span&gt;.Requires(&lt;span style="color: rgb(163, 21, 21);"&gt;"entityId"&lt;/span&gt;, entityId != &lt;span style="color: rgb(43, 145, 175);"&gt;Guid&lt;/span&gt;.Empty);&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;span style="color: rgb(43, 145, 175);"&gt;Contract&lt;/span&gt;.Requires(&lt;span style="color: rgb(163, 21, 21);"&gt;"entityType"&lt;/span&gt;, entityType != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.EntityId = entityId;&lt;/li&gt; &lt;li&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.EntityType = entityType;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&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;&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.OperationRequestType = operationRequestType;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;#endregion&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Each operation request has an operation type, indicated using the following enumeration:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6bd8c12c-9301-48ef-95eb-58a27b9460e0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;OperationRequestType&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2.5em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;namespace&lt;/span&gt; RapidRepository.Context&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; The type of operation requested.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;enum&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Specifies an Add operation.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Add = 0,&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Specifies an Update operation.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Update = 1,&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; Specifies an Delete operation.&lt;/span&gt;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(128, 128, 128);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 128, 128);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Delete = 2&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;The methods for adding and removing OperationRequests reside on the RapidContext class, they are:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:28043c16-212f-4081-9b98-f0288b0aedea" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Add Operation Request&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; AddOperationRequest(&lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequest&lt;/span&gt; operationRequest)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5f2ef311-09c0-465c-9a86-458807042bcc" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Remove Operation Request&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DeleteOperationRequest(&lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequest&lt;/span&gt; operationRequest)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:957a3905-fc7d-4d0f-ac88-c8c4f26aaae0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Delete All Operation Requests&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; DeleteAllOperationRequests()&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;The collection of pending OperationRequests live within a collection: RapidContext.CurrentContext.operationRequests&lt;/p&gt;  &lt;h1&gt;Example&lt;/h1&gt;  &lt;p&gt;So, the following is an example of how this can be used.&lt;/p&gt;  &lt;p&gt;In this example, at the end of a game the users score is persisted to the database by default so it is added to the repository:&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e4245151-8fd6-410c-9fd6-9a45f8200b13" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Add User Score&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ScoreRepository&lt;/span&gt; scoreRepository = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;ScoreRepository&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Score&lt;/span&gt; score = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Score&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;score.Results.Add(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Result&lt;/span&gt;() { Score = 123, UserName = &lt;span style="color: rgb(163, 21, 21);"&gt;"Joe"&lt;/span&gt; });&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;scoreRepository.Add(score);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Now, before leaving the page and submitting the changes, you give the option of allowing the user to not save the score.&lt;/p&gt;  &lt;p&gt;To be sure the score is not saved, you need to find it and remove it from the pending changes (OperationRequests).&lt;/p&gt;  &lt;div style="padding: 0px; margin: 0px; display: inline; float: none;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8438f2dc-bd4f-41d8-90f4-209c965dc1d3" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px solid rgb(0, 0, 128); color: rgb(0, 0, 0); font-family: 'Courier New',Courier,Monospace; font-size: 10pt;"&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(0, 0, 128); color: rgb(255, 255, 255); font-family: Verdana,Tahoma,Arial,sans-serif; font-weight: bold; padding: 2px 5px;"&gt;Remove Add Operation Request&lt;/div&gt; &lt;div style="background: none repeat scroll 0% 0% rgb(221, 221, 221); overflow: auto;"&gt; &lt;ol style="background: none repeat scroll 0% 0% rgb(255, 255, 255); margin: 0pt 0pt 0pt 2em; padding: 0pt 0pt 0pt 5px;"&gt; &lt;li&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequest&lt;/span&gt; addRequest = &lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.operationRequests&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Where(x =&amp;gt; x.OperationRequestType == &lt;span style="color: rgb(43, 145, 175);"&gt;OperationRequestType&lt;/span&gt;.Add).First();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: none repeat scroll 0% 0% rgb(243, 243, 243);"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;RapidContext&lt;/span&gt;.CurrentContext.DeleteOperationRequest(addRequest);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Ok, even though this example is a little simplistic and contrived, you can see that you have a fair amount of control over the context and you can dig deeper into the operations of the database if required.&lt;/p&gt;  &lt;p&gt;You can download Release V1.0, the source code and an example phone app from the following &lt;a href="http://rapidrepository.codeplex.com/" title="http://rapidrepository.codeplex.com/" mce_href="http://rapidrepository.codeplex.com/"&gt;http://rapidrepository.codeplex.com/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;I hope this&amp;nbsp; is useful.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7640028" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item><item><title>Windows 7 Phone Database Rapid Repository – Queries and Views Proposal</title><link>http://weblogs.asp.net/seanmcalinden/archive/2010/11/09/windows-7-phone-database-rapid-repository-queries-and-views-proposal.aspx</link><pubDate>Tue, 09 Nov 2010 22:01:35 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7639051</guid><dc:creator>SeanMcAlinden</dc:creator><slash:comments>1</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/seanmcalinden/commentapi.aspx?PostID=7639051</wfw:comment><comments>http://weblogs.asp.net/seanmcalinden/archive/2010/11/09/windows-7-phone-database-rapid-repository-queries-and-views-proposal.aspx#comments</comments><description>&lt;p&gt;Hi All,&lt;/p&gt;  &lt;p&gt;I’m about to start working on the query side of the &lt;a title="Windows 7 Phone Database Rapid Repository" href="http://rapidrepository.codeplex.com/"&gt;Rapid Repository&lt;/a&gt; as I think this will be the most important requirement for the next release (which I am hoping will come pretty soon).&lt;/p&gt;  &lt;p&gt;My current plan is to do something fairly simple but I thought I’d publish the idea first in case any would prefer a different implementation.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="5"&gt;Proposed implementation&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Setup&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Queries will be done against View Models.&lt;/p&gt;  &lt;p&gt;A view model will be a simple class which implements an interface IRapidView&lt;em&gt; (this will enforce that the entity id is captured within the view model class).&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;The view model will or should be a flattened subset of an entity, perfect for displaying on a page.&lt;/p&gt;  &lt;p&gt;An example could be something like the following:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c1a89feb-0dfd-4e94-a5e2-b174ddebbc4f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;View Model Example&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IRapidView&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Guid&lt;/span&gt; Id { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;        &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; FirstName { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; PostCode { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;    }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;To setup the view, at application start up there will be a method similar to the following: &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:61f8ca27-9a6e-45a1-94de-938c749651aa" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Setting up a View at startup&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;RapidRepository.AddView&amp;lt;&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;, &lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt;(c =&amp;gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt; { FirstName = c.FirstName };&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            })&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Also, I am proposing a filtering feature during setup where linq / lambda can be used to ensure the view filters out any unwanted data – it will look similar to the following:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:87301b60-9b11-421a-bf6b-e80be15e8840" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Filtering the View&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;RapidRepository.AddView&amp;lt;&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;, &lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt;(c =&amp;gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            {&lt;/li&gt; &lt;li&gt;                &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt; { FirstName = c.FirstName };&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;            })&lt;/li&gt; &lt;li&gt;            .Filter&amp;lt;&lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt;(cv =&amp;gt; cv.FirstName != &lt;span style="color:#a31515"&gt;&amp;quot;Sean&amp;quot;&lt;/span&gt; &amp;amp;&amp;amp; cv.PostCode.Contains(&lt;span style="color:#a31515"&gt;&amp;quot;SW1&amp;quot;&lt;/span&gt;));&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Querying the View&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Querying the View will be achieved through a method on the repository that will take the type of view as a generic parameter, this will return a (possibly cached) List&amp;lt;TViewType&amp;gt; that can be queried against using full Linq to Objects.&lt;/p&gt;  &lt;p&gt;This will look similar to the following (lambda):&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8e29225e-5e35-4cb2-aafd-f453d9ea68e6" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Querying the View&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;Repository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;&amp;gt; customerRepository = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Repository&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;Customer&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt; results = customerRepository.Query&amp;lt;&lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt;().Where(x =&amp;gt; x.PostCode.Contains(&lt;span style="color:#a31515"&gt;&amp;quot;SW1&amp;quot;&lt;/span&gt;)).ToList();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;or Linq&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:abed8a27-e46f-4ea7-8d1c-586e06fa88b7" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Querying the View with linq&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt; results = (&lt;span style="color:#0000ff"&gt;from&lt;/span&gt; c &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; customerRepository.Query&amp;lt;&lt;span style="color:#2b91af"&gt;CustomerView&lt;/span&gt;&amp;gt;()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;                                         &lt;span style="color:#0000ff"&gt;where&lt;/span&gt; c.PostCode.Contains(&lt;span style="color:#a31515"&gt;&amp;quot;SW1&amp;quot;&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;                                         &lt;span style="color:#0000ff"&gt;select&lt;/span&gt; c).ToList();&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="4"&gt;Why will this be any better than just loading all the entities?&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are a number of reasons why this would be better than getting all on an entity type (how the current release works).&lt;/p&gt;  &lt;p&gt;The first being the fact that the view model will contain only the data required for the view, this immediately means less data in memory and less to de-serialise.&lt;/p&gt;  &lt;p&gt;The other reasons will include how i intend to store, cache and load the View.&lt;/p&gt;  &lt;p&gt;As a basic idea, I’m going to look at storing a view in one view file per type, and have that (optionally) load into the application cache on start up.&lt;/p&gt;  &lt;p&gt;The view will then be synchronously managed in memory whilst asynchronously managed within isolated storage.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;font size="4"&gt;Conclusion&lt;/font&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Anyway, as a really basic overview, that is my current plan, any thoughts, criticisms or ideas would be most welcome.&lt;/p&gt;  &lt;p&gt;You can download the current release, source code and test windows 7 phone application from &lt;a title="http://rapidrepository.codeplex.com/" href="http://rapidrepository.codeplex.com/"&gt;http://rapidrepository.codeplex.com/&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Kind Regards,&lt;/p&gt;  &lt;p&gt;Sean McAlinden.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7639051" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone/default.aspx">Windows 7 Phone</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Isolated+Storage/default.aspx">Isolated Storage</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+7+Phone+Development/default.aspx">Windows 7 Phone Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/windows+7+phone+database/default.aspx">windows 7 phone database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Development/default.aspx">Windows Phone 7 Development</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7+Database/default.aspx">Windows Phone 7 Database</category><category domain="http://weblogs.asp.net/seanmcalinden/archive/tags/Windows+Phone+7/default.aspx">Windows Phone 7</category></item></channel></rss>