This is a migrated thread and some comments may be shown as answers.

Winforms Databinding DataGridView

6 Answers 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
vb
Top achievements
Rank 1
vb asked on 26 May 2015, 08:33 PM

I'm giving OpenAccess a try. I have created a model project using the ver 2 templates so that my business object's collections are of type TrackedBindingList(Of T). This seems to be working well so far in a DataGridView.

 But what if I want to load a grid with a collection of business objects, do some operations on one or more of them, then hit Save (calling context.SaveChanges). I can't figure any way to created a tracked collection of business objects (or entities).

 At the context level, a collection of Employees,  is returned as an IQueryable(Of Employee), via the GetAll Function, which doesn't appear tracked by the context.

6 Answers, 1 is accepted

Sort by
0
vb
Top achievements
Rank 1
answered on 27 May 2015, 11:22 AM
Hello...anyone from Telerik...? Anyone at all...
0
Doroteya
Telerik team
answered on 29 May 2015, 08:05 AM
Hi,

Thank you for your interest in Data Access.

In general, the context endpoints (IQueryable(of T)) are tracked out-of-the-box. When you retrieve objects through them, modify them, and than call the SaveChanges method, the changes will be persisted to the database without any additional effort on your side. This section in our documentation will give you more details about the CRUD operations with Data Access.

Regarding the scenario on your side, I was unable to completely understand it and therefore I kindly ask you to elaborate a little bit more on the subject:

- What are these business objects?
- How do you retrieve them?
- Do you use some sort of DTOs (custom types) or the persistent types themselves?

Additionally, for the basics of databinding with Data Access, I would recommend you to review the WinForms Quick-Start scenario in our documentation and its implementation in Samples Kit (the Basic Data Binding with Windows Forms sample).

I am looking forward to your feedback.


Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
vb
Top achievements
Rank 1
answered on 29 May 2015, 06:59 PM

Indeed, they are tracked. I'm not sure why it wasn't working for me before.

What I should have asked is, why aren't such collections sortable in a DataGridView?

 Neither IQueryable(Of T) nor TrackedBindindList(Of T) appear to support IBindingList's sorting.

 

My business objects are just classes generated by OpenAccess in a database-first workflow. Nothing mysterious about them.

I retrieve them in the normal fashion:
Dim prod = context.Products.Where(Function(p) p.ProductID = 1).SingleOrDefault ...or...
Dim prods = context.Products...whatever the case may be.

 If I bind prods to a DataGridView using a BindingSource and/or BindingNavigator, sorting is not supported on the collection.

What do you recommend? Thank you for your time. Please try to answer a little quicker than before :) Today would be nice...

0
vb
Top achievements
Rank 1
answered on 29 May 2015, 08:04 PM

Regarding feedback:

So far, I find Data Access to be a fine ORM, as compared to Entity Framework. The API is less cluttered than even EF's DbContext. It handles object generation across junction tables in the datastore quite well (I'm doing database-first).

I do note some odd behavior when generating an object based on a table which contains a column of type byte array. A warning states, "Explicit change tracking required for the array field...etc.", Line: 16707566, Column: 1

 Double clicking on this warning results in an exception, because of the HUGE line number: "The operation could not be completed. The parameter is incorrect."

 What is meant by the warning that explicit tracking is required? How do I explicitly track such a field? Then, how do I get rid of the warnings?

I also note that generated classes contain an Import of the model namespace. This seems unnecessary.

Also, your emitted VB is really (really) bad. It looks like C#, which quite defeats the purpose. Y'all are in serious need of the services of a professional VB developer :)

In spite of the problems, I see promise in it - for two main reasons:
1. Telerik Data Access seems to have very good performance.
2. Telerik Data Access targets SQL Server 2000.

0
vb
Top achievements
Rank 1
answered on 30 May 2015, 02:43 PM
Please disregard the question about the explicit tracking warning. I found the answer I needed on your forum.
0
Doroteya
Telerik team
answered on 04 Jun 2015, 06:56 AM
Hello,

Thank you for the kind words and I am glad you found the details about the validation error.

Regarding sorting and filtering of the results returned by the IQueryable endpoints, handling this in a WinForms scenario with a binding source requires implementation on your side. Here and here you can check what the recommended way of doing these tasks is.

I hope this helps. Let us know if you need further information.


Regards,
Doroteya
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
General Discussions
Asked by
vb
Top achievements
Rank 1
Answers by
vb
Top achievements
Rank 1
Doroteya
Telerik team
vb
Top achievements
Rank 1
Share this question
or