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

Windows Forms (classic) n-tier sample

10 Answers 150 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.
Greg
Top achievements
Rank 1
Greg asked on 16 Feb 2011, 08:07 PM
I am new to Telerik ORM and scratching my way thru the information. We are swtiching from n-tier Windows forms application that uses another low-end ORM package. It works good, but we needed a more professional and supprted package -- hence we purchased OpenAccess.I noticed there are no samples of n-tier classic windows forms samples, just WCF, WPF, APS.Net, etc. Due to corporate rules, we have to stay with classic forms, for now. We need to use Telerik ORM with best practices and I would appreciate any assitance or sample that would explain, direct or show best practices for creating an n-tier using the newest Domain model with classic Windows forms with OpenAccess Domain model scenario. Although our old ORM uses n-tier, it may not be the best method to use with Telrik ORM. Just want to get a good start with this nice looking product and use it as best we can.

10 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 21 Feb 2011, 11:15 AM
Hi Greg,

In this n-tier scenario, does your application (Windows forms) have direct access to the database?

We have a n-tier scenario where an application (also Windows Forms based) "talks" to a set of WCF services hosted on a server and these services "talks" to the database. So the Windows Forms application is capable of doing what the WCF services provides - it never "talks" directly to the database.
As with all WCF services the interface is defined as DataContract classes in conjunction with operations/methods on each of the WCF services. For convenience we have divided the methods into related services, so we have SalesWcfService, StockWcfService, FinanceWcfService and so on. On each of those service there are methods like for the SalesWcfService: CreateOrder, GetOrdersByDate, etc.

I don't know if that's what you are going at...let me know

Regards

Henrik
0
Greg
Top achievements
Rank 1
answered on 21 Feb 2011, 02:13 PM
we currently use an older ORM free product (with MS Emterprise library) and it does not touch the database directly. The UI calls a business/concrete layer (which inherits from an object/schema class) which in turn calls the MS Ent Lib. This scenario has worked and is pretty quick. I looked at the WCF sample, and I admit I am not familer with it. We have over 700 tables to deal with and I am not sure if the wcf secanrio would be repsonsive enough. I had planned to set up a data, business and object layer. I have built a test form and used the domain model, which appears to be the object/data combined in a way using dynamic LINQ from the UI. This could be transferred to a business layer, etc. but wanted to know if Telerik had a classic windows form sample withouit WCF that could be used as a guide for best practices with the product. I noticed a sample was supposed to be in 2010 Q3, but havn't seen it. Thank you for your reply.

--/Greg
0
Accepted
IT-Als
Top achievements
Rank 1
answered on 21 Feb 2011, 04:59 PM
Ok Greg, this is a classic misunderstanding...from my side, sorry... you said "tier" in your title... but what you're actually asking is how to layer your application...  So you'll still have two tiers. The application/client tier (Windows Forms) and the database tier/server, right?

So layering your application into a business and persistence layer as a separation of concern could be done this way... always have an eye on where your transaction demarcation is..  Transaction.Begin and either Transaction.Commit or Rollback

For example the layering could be like this:

in: BusinessLayer, class: CustomerService, method: CreateCustomer you can have

Transaction.Start();

Model.Customer customer = new Customer();
customer.CountryOfOrigin = GlobalizationService.GetCountryByIsoCode("GB");
customer.discountRate = 10;

// TODO: Ste more properties on the customer

Transaction.Commit();

Notice that GlobalizationService in the above code is a class in the persistence layer having a method called GetCountryByIsoCode returning a Model.Country persistent instance.
So the basic idea is this...  methods in your business layer gets called by your application/client and methods in your persistence layer gets called by methods in your business layer.
Whenever, you need to set a reference field or load some other kind of persistent object from your business layer you go to a method in your persistence layer to do the job for you.

Hope this was what you needed...

Regards

Henrik


0
Greg
Top achievements
Rank 1
answered on 21 Feb 2011, 05:14 PM
tier and layer are same to me. So you suggest what I already am doing. it is very simialer to ORM we are currently using where the UI calls a business tier/layer which has a transaction manager for commit/rollback which calls the data tier/layer then returns a business object. The main difference is that I inherit the metadata (schema) for the  db table in the business. thanks for the answer as it tells me what I need to move forward.
0
Petko_I
Telerik team
answered on 21 Feb 2011, 09:07 PM
Hi Greg,

The N-Tier example you are referring to is actually meant to use plain WCF services. The example will be similar to the Sofia Car Rental  series we have for WPF and Silverlight. We are working on this example and will do our best to include it into the OpenAccess SDK browser as soon as possible. We see that what you are actually after is the layering explained by Henrik. Unfortunately, we do not have an example that covers this case but we may consider any suggestions you may give us as to what you find is useful to demonstrate. There is, however, an example that shows best practices for managing the life cycle of a context in a Windows Forms application. We do hope you will find it useful.

Feel free to contact us, should you need further assistance.

Greetings,
Petko_I
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
IT-Als
Top achievements
Rank 1
answered on 22 Feb 2011, 09:16 AM
Hi Greg,

Glad I could point you (or confirm that you are going) in the right direction.. :-)

Thanks for elaborating on the best practices, Petko.

Regards

Henrik
0
Greg
Top achievements
Rank 1
answered on 22 Feb 2011, 02:50 PM
So far so good.

in my code behind for a simple test task:

 

Dim getData As New objRec
Me.recGrid.DataSource = getData.getByDate("02/08/2011")

 


in business layer

 

Public Function getByDate(ByVal pDate As String) As IList(Of objRec)

 

 

 

Dim context As TestEntityDiagrams = ContextFactory.ObtainContext()

 

 

 

Dim results As IList(Of objRecs) = context.objRec.Where(Function(c) c.FileDate = pDate).ToList()

 

 

 

Return results

 

 

 

End Function

 


and the entity class has the context factory and entities
0
IT-Als
Top achievements
Rank 1
answered on 22 Feb 2011, 02:57 PM
Hi Greg,

Looks nice..

Although you are not using transactions in the sample (you do not do any writes to the database) yet, I found it a very good "practice" to think in terms of business value...    What is the goal of the method in the business layer... typically you'll end up with a transaction demarcation that streamlines fine against the { and the } in your business layer method.

Regards

Henrik
0
Greg
Top achievements
Rank 1
answered on 22 Feb 2011, 03:05 PM
i wouldn't say nice, just a quick minimal conceptual test :). yep. working my way to that now. We currently use an older OR/M and *trying* to refactor using Telerik. We have the transaction demarcation in the old one, but still working thru the programmers reference to see how you do it -- hence best practices. I appreciate your assistance -- you have been very helpful. 
0
Petko_I
Telerik team
answered on 24 Feb 2011, 07:52 PM
Hi Greg,

We are glad you have found answers to your questions. We would like to remind you that if you have questions during the refactoring we are here to help. We do hope you will find the help topics useful.

Kind regards,
Petko_I
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Getting Started
Asked by
Greg
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
Greg
Top achievements
Rank 1
Petko_I
Telerik team
Share this question
or