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
Start with simple examples which shows the basics and than go to an end-to-end example.
Including Client and Server side domain validation.
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.
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
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
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
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
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
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.
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