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

DAL using Domain Model

6 Answers 128 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 14 Oct 2010, 03:45 AM
I have been using Open Access by creating the DAL in a class library and adding a reference in my Winform application. How do I complete the same task using a Domain Model. Do I create the Domain Model in the class library and then add a reference in the Winform application? Is this all I need to do? Is there an VB example or some documentation? 

6 Answers, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 15 Oct 2010, 06:40 PM
Hello James,

You can create your domain model in a class library project and then from the windows forms project reference the DAL. The only thing you need to do is add references to the Telerik.OpenAccess, Telerik.OpenAccess.35.Extensions assemblies and copy the connection string in the application configuration file. From then on, you can start consuming the domain model with full power in the windows forms project. We have a quick start section in the online help that describes the steps you need to follow. Unfortunately, we do not have a windows forms example with VB.NET, however we plan to introduce one for the Q3 release. You can benefit from looking at the following examples nevertheless (most of them are web).

Should you need further information, do not hesitate to contact us right away.

Greetings,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 17 Oct 2010, 05:15 PM
I tried the quick start section and am having problems with the Delete and AddNew sections. Is the following code conversion correct?

Delete Section
C#
{
   Car selectedCar = this.dataSource.Current as Car;
   
if ( selectedCar == null )
       
return;
   (
this.dataSource.DataSource as IList<Car> ).Remove( selectedCar );
   
this.dbContext.Delete( selectedCar );
}

VB
If True Then
	Dim selectedCar As Car = TryCast(Me.dataSource.Current, Car)
	If selectedCar Is Nothing Then
		Return
	End If
	TryCast(Me.dataSource.DataSource, IList(Of Car)).Remove(selectedCar)
	Me.dbContext.Delete(selectedCar)
End If

AddNew Section


C#



{
   Car newCar = new Car();
   newCar.Make =
"WV";
   newCar.CarID = 100;
   newCar.Model =
"Golf";
   (
this.dataSource.DataSource as IList<Car> ).Add( newCar );
   
this.dbContext.Add( newCar );
}





VB
If True Then Dim newCar As New Car() newCar.Make = "WV" newCar.CarID = 100 newCar.Model = "Golf" TryCast(Me.dataSource.DataSource, IList(Of Car)).Add(newCar) Me.dbContext.Add(newCar) End If

0
James
Top achievements
Rank 1
answered on 17 Oct 2010, 05:18 PM
Is there a way to connect a datasource to a persistent class without writing code? I am able to do so and the grid displays the correct fields, however no data is loaded at runtime.
0
Petko_I
Telerik team
answered on 20 Oct 2010, 06:15 PM
Hello James,

As far as I see the conversion is correct. Can you describe what the errors or unexpected behaviors are when you follow the guide? I have prepared a sample VB example which demonstrates CRUD operations with a RadGridView. There isn’t a fully automated way to bind a collection of persistent objects directly as a data source. Usually a BindingSource acts as a mediator. Can you have a look at the example and see if it answers your questions?

I am looking forward to your reply.

Best wishes,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
James
Top achievements
Rank 1
answered on 20 Oct 2010, 08:45 PM
I tried the sample and it works fine.

You said, "There isn’t a fully automated way to bind a collection of persistent objects directly as a data source."

Are there plans for one in the near future? (ie 2010 Q3)
If not when?

Doesn't not having a fully automated way kill the idea of RAD?
I can't even set the column properties to display only selected columns since the RadGridView is not directly bound to the DataSource or BindingSource

I like the Visual Designer which is a huge improvement. However it's not worth it if I have give up binding the persistent objects to controls.

This is your description of Open Access:

Transparent Persistence is therefore, the ability to directly manipulate data stored in a relational database using an object-oriented programming language, i.e., no SQL statements are needed to retrieve, insert, or update objects in the database and the tasks associated with conversion between your object model and your table model are done automatically. OpenAccess ORM is intended to be used with all managed languages, such as Visual Basic.NET, C#, J# etc. and it has very few restrictions on the data model used.

Is this statement still correct for the current version?



0
Petko_I
Telerik team
answered on 22 Oct 2010, 06:26 PM
Hi James,

We have not planned adding features for windows forms automated binding with a domain model context in the near future. Actually, we do not intend to provide functionality such as the ObjectView and ObjectProvider for the domain model. Other conveniences may come into action to facilitate the usage of the domain model. If you really feel that something is necessary, you can place a feature request. All suggestions are highly welcome. At this point, we have considered that the available means to bind a collection of persistent objects to a control are flexible enough. What we might be lacking is a comprehensive example or related documentation that covers a binding scenario from scratch. We are currently working towards the expansion of our set of examples and this is high priority for the Q3 release.
The paragraph you have cited refers to adopting object-oriented tools at the appropriate level of abstraction so that the user is programming in terms of a specific domain. This means that we are trying to isolate the database specific details from the object-oriented model so that the user worries only about business rules and object-oriented development. The complete automation of the integration between a domain model and a UI control goes slightly beyond the scope of an ORM tool.

Do not hesitate to share your proposals with us. Any arguments you feel are important will be accepted and taken into consideration.

All the best,
Petko_I
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Getting Started
Asked by
James
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
James
Top achievements
Rank 1
Share this question
or