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

Q1 2010 nTier Implementation

14 Answers 262 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.
Chris Gethin
Top achievements
Rank 1
Chris Gethin asked on 21 Mar 2010, 03:04 PM

I'm currently evaluating Open Access to determine its suitablility for implementing it in a new release of an existing mission critical nTier ASP.NET web application. I've not used OA before but I have previous ORM experience using NHibernate, which I view as a very strong framework in this field. OA's ability of developing 'bottom up' and integrating with VS without the need for any additional tools or libraries has prompted me to look into this as potentially it may be a more cost effective solution in terms of development time to 'plug in' to the existing application.

 

I have attempted to create a proof of concept using OA and unfortunately I am having difficulty finding support materials for using the newly added Domain Model functionality in an nTier application. Are there any materials available to advise on how to do this, or as Q1 has only recently been released will it take some time before such material is available?

 

In the case of no material yet being available, would you be able to answer the following questions please?

 

Am I right in thinking that as the domain model auto-generates DAOs it should be added to the code library that holds the relevant business logic layer and can then maintain encapsulation and only be exposed to higher layers through the business logic layer?
This is the approach that I was trying to follow, but when calling a method from the presentation layer that interacts with the domain model via the business logic layer the following exception is being thrown 'No persistent class could be found. To define persistent classes use the [Persistent] attribute at the class level. If multiple projects are used additional references must be made in the configuration file. To update the required references use 'Update Config References' from the OpenAccess menu.'. 
Could you please advise on what is likely to be the problem here?

 

Also, for bottom-up implementation in a large scale application, would you recommend using the new domain model and designer functionality or would it be best to look at the Reverse-Mapping wizard instead?

 

Thanks,

Chris.

14 Answers, 1 is accepted

Sort by
0
Michael Josiah
Top achievements
Rank 1
answered on 23 Mar 2010, 09:39 AM
I am also looking for similar answers when using the new designer

1) N-tier scenario seems to crash out with error mentioned by the previous poster.

2) I dont see an attach or detach method on the context, so what is the best way to pass data between the business and UI layers (new and modified data). I hope we dont have to pass the context around. 

3) I want to audit any changes made. What is the best way to go about doing this?

The designer method seems a lot easier and cleaner to work with then the previous OA entities. I love the fact that I dont need to mention scope. It seems very similar to Linq2SQL which I think is a brilliant idea as it would make it much easier for developers to work with. I think I need more concrete examples. The only example I have seen is too simplistic and only shows how to read data. I need examples of how to
1)Insert Data
2)Delete Data
3)Update Data
4) Move data around within BLL and UI layers
5) Example using a very simple manager or provider based model.
0
Sörnt Poppe
Top achievements
Rank 1
answered on 23 Mar 2010, 02:01 PM
That will be really appreciated!

Start with simple examples which shows the basics and than go to an end-to-end example.
Including Client and Server side domain validation.
0
Accepted
Jordan
Telerik team
answered on 25 Mar 2010, 09:20 AM
Hi all,

Unfortunately we still do not have enough documentation for the new visual designer and all associated functionality. We are working on improving the documentation as we speak.
Regarding the attach / detach functionality of the new context, we will be implementing this for the Q2 2010 release. It may be available earlier through some preview / beta release.

Regarding moving data through the layers of an n-layer application, you should not have problems using the persistent classes that are generated for you as long as you keep the instance of the context / scope alive. This is needed because a lot of functionality of a persistent class like for example lazy loading depends on the scope / context.

@Chris
Yes, it is best if the persistent classes generated by OpenAccess are in a separate assembly / project.
And yes, for new development we recommend using the new visual designer and the context. This is  where new development will be focused (on our side).

This exception that you are getting, "No persistent class could be found" can happen in two cases:
1. you have added an .rlinq item in an already enhanced project that was created earlier using the reverse mapping wizard. Due to the changes in the enhancer you cannot have a project where both approaches for working with OpenAccess coexist. You can either create an .rlinq item using the visual designer or use the reverse mapping wizard. An updated version is now available for download that (besides of containing some important fixes) will prevent you from mixing both approaches.
2. for some reason the product is not installed correctly and the assembly that contains the persistent classes cannot be enhanced

I hope this helps. Do not hesitate to write again if you have more questions or suggestions.

Greetings,
Jordan
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
Michael Josiah
Top achievements
Rank 1
answered on 25 Mar 2010, 05:20 PM
Hi

To keep the context alive will I need to use one of the following approaches

1) Pass the context around through method parameters
2) Use the masterpage scenario
3) Use Httpmodule approach
4) Use httpcontext approach

I personally dislike all four approaches. It just does not feel clean and it just seems like bad plumbing to fix the leak (terrible reference I know). Is there any other approach I can use? or will I have to wait for the attach/detach feature in Q2. Please tell me that there is a better way to do this and I dont need to wait for q2.

Thanks
0
IT-Als
Top achievements
Rank 1
answered on 26 Mar 2010, 11:22 AM
Hi Michael (and others)

I don't see the reasons why you dislike the "keep the scope/context alive" during your request (server)?

We have done this with great success in our WCF services, meaning once a request comes in for one of our service methods a object scope is pinned to the request and it is released again when the request ends. Eventually see the concepts in my blog..

This enables us to pass persistent objects around in our layers (WCF service, Business services, Repository services) once retrieved...and that lazy loading is still done whenever you access a property that was not originally fetched by the repository method that loaded the object instance.
I cannot see why attach/detach functionality will be any better, because as far as I understand the concept...it will disable lazy load once detached.

Regards

Henrik


0
Michael Josiah
Top achievements
Rank 1
answered on 26 Mar 2010, 02:37 PM
I may be a bit of a lazy coder. I want to focus all my time on the business logic rather then spend time trying to implement a solution like your (which is actually pretty damn good). I just want an ORM and can use immediately. Just had a quick look at EF4 and their self tracking entities http://msdn.microsoft.com/en-us/magazine/ee335715.aspx and it's got my juices going. Take a look at the example on that link and you can see just how easy it is to start running with their solution.

Being a Telerik fan, I would rather use their solution, but this time round looks like MS might have something a little closer to what I am looking for. Hopefully Q2 might bridge this gap.
0
IT-Als
Top achievements
Rank 1
answered on 26 Mar 2010, 02:53 PM
Hi Michael,

Thanks for the nice words :-)

I am also devoted to spending my time doing business logic rather than architecture infrastructure (I jjust love doing a good architecture candidate)

I have already looked at the link previously (thanks for posting anyway) and it got me going.."This is what I have been looking for".. but something also strikes me: MS have a great advantage because this "feature" of detaching and attaching objects to the context and have them change tracked is part of the .NET framework 4.. So what I am trying to say here: If you have .NET on both client and server (and if you control both) you will have the ability use their change tracking... if not...you're lost and must develop something yourself.

In our solution (and I will blog about it very soon) we have a small super class which all our client side proxy DataContract classes inherits from.. This class can track changes for all DC classes, so whenever a DC class instances comes back to the WCF service, the service can "inspect" that instance to see if it's EditState (that's what we call it).. is None, Dirty, New or Delete.. and then determine what to do.
Again it is something similar as to what ms do...and it has the same advantage...or disadvantage if you prefer that...  you have to have some code sharing (in our example the super class for dc proxies and in ms example the .NET framework 4 itself) between client and server....and code sharing only works if you control both client and server...  :-)
Do you "see" where I am going...?

Anyway I posted a follow up on your thread which is actually what we are talking about here...

Regards

Henrik


0
Michael Josiah
Top achievements
Rank 1
answered on 26 Mar 2010, 03:15 PM
I guess the optimal solution here would be for OA to go down the route of the DTO approach. However it just struck me. How is change tracking managed in a DTO approach.?
0
Michael Josiah
Top achievements
Rank 1
answered on 26 Mar 2010, 03:31 PM
One more point, I thought the self tracking entities in EF4 are simply POCO entities, with a little bit of logic to manage the tracking. So in essence isn't it very similar to DTO's? 
0
IT-Als
Top achievements
Rank 1
answered on 26 Mar 2010, 03:46 PM
You're absolutely right... Self Tracking POCOs in EF4 is essentially DTO's with a twist of tracking mechanism (like in our implementation of the DC proxy super class).. This is exactly my point.

So putting tracking into OA DTO could be managed the very same way as we (or EF4 does it)..but it needs code sharing then...as I see it


0
Michael Josiah
Top achievements
Rank 1
answered on 26 Mar 2010, 04:18 PM
I personally would love it if OA employed the use of self tracking entities. This would eliminate the need to keep the context alive during calls. For most part I control both the server and client (web apps and sliverlight), so this approach would suite me just fine. However when working on a project where I have no control over the client then I would result to a custom DTO which would hold a subset of the data (remove fields not needed). I would probably just generate the DTO from my db model, strip irrelevant fields and have it mapped back to my OA Entities in the BLL or DAL. Now if Telerik could also provide an automated (or partially automated) why of doing this, then I will just go ahead and wet my pants for joy.

For now EF4 is still a little better for me. Would love to know what OA has planned for Q2, it could very well win me back.
0
IT-Als
Top achievements
Rank 1
answered on 26 Mar 2010, 06:49 PM
Hi Michael,

Maybe I do not understand your architecture correctly, but in my opinion it does not eliminate the need to keep the context alive during the request on the server side, since you will then loose lazy loading. But if you do not need the lazy load then...

Often you do need the lazy load, for example:

You retrieve an Account object in the repository layer and then you perform som calculations on the Account->Entries collection in the business layer. In case you didn't retrieve the AccountEntry collection during load in the repository layer it will get loaded on demand when you do the calculations in the business layer.

Regards
Henrik


0
Jordan
Telerik team
answered on 31 Mar 2010, 11:35 AM
Hello guys,

I just wanted to let you know that we are considering both DTOs and self tracking entities along with other possible options for Q2. Also, now that we are using t4 templates for code generation (with the new visual designer) one can easily imagine how you could have templates for generating persistent classes that work well for example with XAML data binding or WCF services or whatever you need.

It will be great if you can share with us any suggestions that you have.

All the best,
Jordan
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
IT-Als
Top achievements
Rank 1
answered on 31 Mar 2010, 11:51 AM
Hello Jordan,

That sounds f.a.n.t.a.s.t.i.c :-)

I have suggested something in this thread...  maybe it doesn't go along with the thoughts of the development team, but it is a suggestion.

Regards

Henrik
Tags
Getting Started
Asked by
Chris Gethin
Top achievements
Rank 1
Answers by
Michael Josiah
Top achievements
Rank 1
Sörnt Poppe
Top achievements
Rank 1
Jordan
Telerik team
IT-Als
Top achievements
Rank 1
Share this question
or