Telerik Forums RSShttp://www.telerik.com/urn:uuid:dd26491d-0f68-420a-a467-87431e458625http://www.telerik.com/forums/permalink/HUkm3WgPCkKkZ4dDHkWGJQAre Objectviews Still relevant?Hi kieron,
<br />
<br />
Please let me apologize for misleading you with my last post.<br />
I regret to say that this statement&nbsp;is not true:<br />
"Getting back to your question what is the difference:<br style="text-align: -webkit-auto; background-color: #eeeeee;" />
<ul style="text-align: -webkit-auto; background-color: #eeeeee;">
<li>ObjectView supports IQueryable as underlying collection for the data source, which means you can easily query data, shape the result and enjoy LINQ in your code. For example you can have server side sorting and paging.</li>
</ul>
"&nbsp;&nbsp;<br />
<br />
Actually, the ObjectView is an obsolete component in our product and has not been updated after the new context-based API, directed to LINQ development was introduced.&nbsp;<br />
<br />
&nbsp;If you want to do sorting and filtering using <em>ObjectProvider </em>you have to use <strong>OQL </strong>as the query language instead of&nbsp;<strong>LINQ</strong>.<br />
OQL has similar syntax to SQL, and it &nbsp;issues queries as strings not as expressions as LINQ does.<br />
<br />
If you like to filter your data on the server side you can add a "WHERE" clause to the OQL like this:<br />
<div class="tFormatCodeBlock supportThreadCodeBlock" style="border:1px solid #7f9db9;border-image: initial; overflow-y: auto;" id="highlighter_54123">
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">objectProvider.OQLStatement = </code><code style="color: blue;">"SELECT * FROM CategoryExtent AS x <strong>WHERE x.CategoryName = 'Hatchback'</strong>"</code><code style="color: #000000;">;</code></span></div>
</div>
<br />
In order to sort data add "ORDER BY" clause like this:<br />
<div class="tFormatCodeBlock supportThreadCodeBlock" style="border:1px solid #7f9db9;border-image: initial; overflow-y: auto;" id="highlighter_52073">
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">objectProviderCategory.OQLStatement = </code><code style="color: blue;">"SELECT * FROM CategoryExtent AS x ORDER BY x.CategoryName ASC"</code><code style="color: #000000;">;</code></span></div>
</div>
<br />
Our <a href="http://www.telerik.com/help/openaccess-orm/oql-programming-guide-overview.html" target="_blank">online documentation</a> contains a lot more information about OQL and how to use it.<br />
<br />
Paging results get very tricky to do using OQL.<br />
Depending on your various scenarios you can use <em>ObjectProvider/ObjectView</em> or <em>BindingSource</em>.<br />
<ul>
<li><em>ObjectProvider/ObjectView</em> is good for plain binding for <em>DataGridViews </em>with sorting done via OQL and no paging;</li>
<li><em>BindingSource </em>+ manual handling of data context and LINQ queries is good for more advanced scenarios;</li>
</ul>
<p>Regarding about your question about multiple object views - you need a pair of <em>ObjectProvider/ObjectView</em> for each&nbsp;independent&nbsp;bound control in your forms. If you share the pair between two bound controls expect them to share data too. You can reuse the same data context for all bound controls.&nbsp;<br />
<br />
Again, I apologize for any inconvenience this might have caused you.<br />
<br />
</p>
Greetings,<br />
Viktor Zhivkov <br />
the Telerik team
<div class="forumBaloonTop"></div>
<div class="forumBaloon"><strong>
Telerik OpenAccess ORM Q1 2012 release is here</strong>! Check out <a href="http://www.telerik.com/products/orm/whats-new.aspx">what's new</a> or <a href="http://www.telerik.com/download-trial-file.aspx?pid=638">download a free trial &gt;&gt;</a>
</div>
<div class="forumBaloonBottom"></div>urn:uuid:9a5d1db7-777e-4e9b-9529-cfe661ade69chttp://www.telerik.com/forums/permalink/tx1dmn53m06VKc_mYa3mnAAre Objectviews Still relevant?Thanks for that Info that has got me starting using object views. you mentioned sorting and paging just wondering if you can provide examples on that as i cant find anything on how to sort the objectviews results. Also a quick example on filtering would be great as well.<br />
<br />
Also just wondering if i have a form which as 3 objectviews for 3 different tables, do i need to create 3 different objectproviders and assign to the different objectviews or can i create one objectprovider and assign that to all 3 of the objectview? im a little confused as it would seem to get messy having to create an objectprodier for each object view on a windows form?urn:uuid:438d1084-9e37-43c2-b1f0-e661a9b21614http://www.telerik.com/forums/permalink/hBCNQzeewkOx8OZhqbIWFAAre Objectviews Still relevant?Hi Kieron,
<p>You are totally right that ObjectView can offer you easier and faster way to bind data control to domain context. The documentation in the "Old API" describes how to use the type, but misses one important topic - how to use it with the current API, and it will be updated accordingly.<br />
I have prepared a quick sample how to bridge the gap between the new context API and the ObjectProvider/ObjectView data binding approach. Please see the attached zip.<br />
<br />
In nutshell you should extend the domain model class using a partial class and add an additional property:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>
</p>
<div class="tFormatCodeBlock supportThreadCodeBlock" style="border:1px solid #7f9db9;border-image: initial; overflow-y: auto;" id="highlighter_13990">
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #008200;">//Expose the ObjectScope of the context for the ObjectProvider to consume</code></span></div>
<div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #006699; font-weight: bold;">public </code><code style="color: #000000;">IObjectScope Scope</code></span></div>
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">{</code></span></div>
<div style="background-color: #f8f8f8;"><span><code>&nbsp;&nbsp;&nbsp;&nbsp;</code><span style="margin-left: 12px !important;"><code style="color: #006699; font-weight: bold;">get </code><code style="color: #000000;">{ </code><code style="color: #006699; font-weight: bold;">return </code><code style="color: #006699; font-weight: bold;">this</code><code style="color: #000000;">.GetScope(); }</code></span></span></div>
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">}</code></span></div>
</div>
<p>Then you can add ObjectProvider and ObjectView from the toolbox to your forms/controls.<br />
Add the following code in the forms/controls code behind:</p>
<div class="tFormatCodeBlock supportThreadCodeBlock" style="border:1px solid #7f9db9;border-image: initial; overflow-y: auto;" id="highlighter_26177">
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><strong><code style="color: #006699;">private </code><code style="color: #000000;">EntitiesModel dataContext = </code><code style="color: #006699;">new </code><code style="color: #000000;">EntitiesModel();</code></strong></span></div>
<div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;">&nbsp;</span></div>
<div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #006699; font-weight: bold;">public </code><code style="color: #000000;">Form1()</code></span></div>
<div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">{</code></span></div>
<div style="background-color: #ffffff;"><span><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><span style="margin-left: 21px !important;"><code style="color: #000000;">InitializeComponent();</code></span></span></div>
<div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;">&nbsp;</span></div>
<div style="background-color: #ffffff;"><span><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><span style="margin-left: 21px !important;"><strong><code style="color: #006699;">this</code><code style="color: #000000;">.objectProvider.SetObjectContext(dataContext.Scope);</code></strong></span></span></div>
<div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">}</code></span></div>
</div>
<br />
Now you can bind you control's DataSource property to the ObjectView instance.<br />
<br />
Getting back to your question what is the difference:<br />
<ul>
<li>ObjectView supports IQueryable as underlying collection for the data source, which means you can easily query data, shape the result and enjoy LINQ in your code. For example you can have server side sorting and paging.</li>
<li>ObjectView is wired to the data context so you can enjoy automatic persistent object tracking which enables you to employ easily SaveChanges() method without any additional code.</li>
</ul>
<div>Lastly we do not consider ObjectView/ObjectProvider pair&nbsp;redundant.<br />
<br />
Don't hesitate to contact us again if you have any other questions.<br />
<br />
</div>
Greetings,<br />
Viktor Zhivkov <br />
the Telerik team
<div class="forumBaloonTop"></div>
<div class="forumBaloon"><strong>
Telerik OpenAccess ORM Q1 2012 release is here</strong>! Check out <a href="http://www.telerik.com/products/orm/whats-new.aspx">what's new</a> or <a href="http://www.telerik.com/download-trial-file.aspx?pid=638">download a free trial &gt;&gt;</a>
</div>
<div class="forumBaloonBottom"></div>urn:uuid:4ec78db9-9455-4816-833e-00edfac14c90http://www.telerik.com/forums/permalink/uY3HTlWUFkiDPgDt-sFMkAAre Objectviews Still relevant?I have been using Openaccess for a while now, i use bindingsources for binding data to all my controls etc. but i see thers the objectview which inherits from the binding source. In the documentation the objectview isonly mentioned in the "old api" section, and i can find hardly any new mention of using the objectview on the forums etc. so with the latest domain context system is the objectview redundant? or should i switch from using bindingsources to objectviews? if so whats the difference /benefit?