<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Using jQGrid with DbContext (Code First techinques)</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/using-jqgrid-with-dbcontext-code-first-techinques</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/using-jqgrid-with-dbcontext-code-first-techinques/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>pcapozzi on Using jQGrid with DbContext (Code First techinques)</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/using-jqgrid-with-dbcontext-code-first-techinques#p25912</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/using-jqgrid-with-dbcontext-code-first-techinques#p25912</guid>
        	        	<description><![CDATA[<p>To&#160;get jQgrid to work with the DBContext object&#160;you next to build a method that exposes an&#160;ObjectSet from the dbContext objext.</p>
<p>eg.</p>
<p><span>&#160;</span><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"> </span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#60;</span></span><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">Job</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#62; Jobset { <br /></span><br /></span></p>
<p>ObjectSet</p>
<p><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;">&#160;&#160; get</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> { <br /></span><br /></span></p>
<p><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">&#160;&#160; ObjectContext</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> ctx = ((</span></span><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">IObjectContextAdapter</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">)db).ObjectContext; <br /></span><br /></span></p>
<p><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;">&#160;&#160; return</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> _Jobset ?? (_Jobset = ctx.CreateObjectSet&#60;</span></span><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">Job</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#62;(</span></span><span style="font-family: Consolas; color: #a31515; font-size: x-small;"><span style="font-family: Consolas; color: #a31515; font-size: x-small;"><span style="font-family: Consolas; color: #a31515; font-size: x-small;">"Jobs"</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">)); </span></span></p>
<p>&#160;&#160;&#160; }</p>
<p>}</p>
<p><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"></span></span></span></p>
<p>private</p>
<p><span style="font-family: Consolas; font-size: x-small;">&#160;</span></p>
<p><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">You then can use this objectSet in&#160; the jQgrid code</span></span></p>
<p><span style="font-family: Consolas; font-size: x-small;">&#160;</span></p>
<p><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"></span></span></span></span></span></p>
<p>ObjectQuery</p>
</p>
<p><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#60;</span></span><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">Job</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#62; filteredQuery = (f == </span></span><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;"><span style="font-family: Consolas; color: #0000ff; font-size: x-small;">null</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;"> ? Jobset : f.FilterObjectSet(Jobset));</span></span></p>
</p>
<p><span style="font-family: Consolas; font-size: x-small;">&#160;</span></p>
<p><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">ObjectSet</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#60;</span></span><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;"><span style="font-family: Consolas; color: #2b91af; font-size: x-small;">Job</span></span></span><span style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: x-small;">&#62; _Jobset;</span></span></p>
]]></description>
        	        	<pubDate>Fri, 10 Feb 2012 00:59:22 +0200</pubDate>
        </item>
        <item>
        	<title>pcapozzi on Using jQGrid with DbContext (Code First techinques)</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/using-jqgrid-with-dbcontext-code-first-techinques#p25858</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/using-jqgrid-with-dbcontext-code-first-techinques#p25858</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I am working with the jQGrid with MVC3&#160;using code first techniques.&#160; This dictates the use of the DBContext object for&#160;the data layer.&#160; I am having trouble gettingthe DBContext to work with ObjectQuery. So in your sample code &#39;jqGridDemo&#39;&#160; there is a line :</p>
</p>
<p>&#160;ObjectQuery&#60;Question&#62; filteredQuery = (f == null ? context.Questions : f.FilterObjectSet (context.Questions));</p>
</p>
<p>I need to use DBContext in place of context.Questions.&#160; If I try :</p>
</p>
<p>&#160;IQueryable&#60;Job&#62; filteredQuery = (f == null ? dbcontext.Jobs : f.FilterObjectSet(dbcontext.Jobs));</p>
</p>
<p>then I get an error message:</p>
<p>"The type arguments for method &#39;TempRxMVC.Controllers.Filters.FilterObjectSet&#60;T&#62;(System.Data.Objects.ObjectQuery&#60;T&#62;)&#39; cannot be inferred from the usage. Try specifying the type arguments explicitly." and also the&#160;line :</p>
</p>
<p>var queryDetails = (from item in pagedQuery select new { item.Id, item.Votes, item.Title }).ToList();</p>
</p>
<p>gives me a error:</p>
<p>"No overload for method &#39;Skip&#39; takes 3 arguments"</p>
</p>
<p>Is there a way to use DBContext instead of&#160;ObjectContext with the grid?</p>
</p>
<p>Thanks for your help!</p>
</p>
<p>PatC</p>
]]></description>
        	        	<pubDate>Wed, 01 Feb 2012 18:03:02 +0200</pubDate>
        </item>
</channel>
</rss>