Some templates for whoever wants to look

Posts   
1  /  2
 
    
cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 09-Dec-2004 18:51:43   

These are inspired by the "controller" templates for CodeSmith supplied by Bert. I've changed the names from *Controller to *Manager.

Not every piece of possible functionality is in there but, there's plenty for it to be useful. Maybe we can use these as a starting point for the LLBLGen TemplateStudio community to build something really useful for us. smile

These were built in about an hour so, they need some work still.

Otis,

If you look at the <~~> block in "EntityManagerBaseTemplate.lpt" you'll see what I was getting at with wanting that stuff to be available to a whole templateset without having to redefine it on every template. I suppose copy/paste is good enough though. wink

Here they are: http://code.caliberweb.com/LLBLGenProManagers.zip

Chris

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Dec-2004 22:54:55   

Sounds great! I'll check them out tomorrow (friday).

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 10-Dec-2004 15:37:42   

Thanks for posting this!

BTW - Found 2 bugs in EntityManagerBase:

You are using rel.RelationEndPoint.Name in the Method names, but this fails for tables that have a relationship with themselves...

Here is the fixed code:


        #region One To Many
        <%  
        foreach(EntityRelation rel in Entity.Relations)
        {
            if(rel.RelationType == EntityRelationType.OneToMany && !rel.UtilizingPropertyIsHidden)
            {
        %>      
        public static EntityCollection Fetch<%=rel.UtilizingPropertyName%>Collection( <%=Entity.Name%>Entity <%=CamelCase( Entity.Name )%> )
        {
            EntityCollection collection = <%=CamelCase( Entity.Name )%>.<%=rel.UtilizingPropertyName%>;
            return FetchCollection( collection, <%=CamelCase( Entity.Name )%>.GetRelationInfo<%=rel.UtilizingPropertyName%>(), 0, defaultSorter );
        }       
        
        public static EntityCollection Fetch<%=rel.UtilizingPropertyName%>Collection( <%=BuildPrimaryKeyParameterList()%> )         
        {
            <%=Entity.Name%>Entity <%=CamelCase( Entity.Name )%> = new <%=Entity.Name%>Entity( <%=BuildPrimaryKeyList()%> );
            return Fetch<%=rel.UtilizingPropertyName%>Collection( <%=CamelCase( Entity.Name )%> );
        }
        <%
            }
        }
        %>
        #endregion
        
        #region Many To One
        <%  
        foreach(EntityRelation rel in Entity.Relations)
        {
            if(rel.RelationType == EntityRelationType.ManyToOne && !rel.UtilizingPropertyIsHidden)
            {
        %>  
        public static <%=rel.RelationEndPoint.Name%>Entity Fetch<%=rel.UtilizingPropertyName%>Entity( <%=Entity.Name%>Entity <%=CamelCase( Entity.Name )%> )
        {
            return (<%=rel.RelationEndPoint.Name%>Entity)FetchNew( new <%=rel.RelationEndPoint.Name%>EntityFactory( ), <%=CamelCase( Entity.Name )%>.GetRelationInfo<%=rel.UtilizingPropertyName%>( ) );            
        }
        
        public static <%=rel.RelationEndPoint.Name%>Entity Fetch<%=rel.UtilizingPropertyName%>Entity( <%=BuildPrimaryKeyParameterList()%> )
        {
            <%=Entity.Name%>Entity <%=CamelCase( Entity.Name )%> = new <%=Entity.Name%>Entity( <%=BuildPrimaryKeyList()%> );
            return Fetch<%=rel.UtilizingPropertyName%>Entity( <%=CamelCase( Entity.Name )%> );
        }
        <%
            }
        }
        %>
        #endregion

Also, sometimes rel.RelationEndPoint.Name = rel.UtilizingPropertyName which cause a compile error in the DeleteWithRelations method. I have added the word Collection to the end of the local collection variable name to avoid this:

        public static bool DeleteWithRelations( <%=ObjectName%>Entity <%=CamelCase(ObjectName)%> )
        {
            #region One to Many
        <%  
        foreach(EntityRelation rel in Entity.Relations)
        {
            if( rel.RelationType == EntityRelationType.OneToMany && !rel.UtilizingPropertyIsHidden )
            {
        %>          
            EntityCollection <%=CamelCase(rel.UtilizingPropertyName)%>Collection = <%=rel.RelationEndPoint.Name%>Manager.FetchCollection( <%=CamelCase(ObjectName)%>.<%=rel.UtilizingPropertyName%> );
            
            foreach( <%=rel.RelationEndPoint.Name%>Entity <%=CamelCase(rel.RelationEndPoint.Name)%> in <%=CamelCase(rel.UtilizingPropertyName)%>Collection )
            {
                <%=rel.RelationEndPoint.Name%>Manager.DeleteWithRelations( <%=CamelCase(rel.RelationEndPoint.Name)%> );
            }
        <%
            }
        }
        %>  

            #endregion

Regards,

Marcus

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 10-Dec-2004 15:56:21   

Thanks for the feeback. I'll check it out when I get into the office. sunglasses

alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 10-Dec-2004 18:22:54   

cmartinbot wrote:

These are inspired by the "controller" templates for CodeSmith supplied by Bert. I've changed the names from *Controller to *Manager.

Not every piece of possible functionality is in there but, there's plenty for it to be useful. Maybe we can use these as a starting point for the LLBLGen TemplateStudio community to build something really useful for us. smile

These were built in about an hour so, they need some work still.

Otis,

If you look at the <~~> block in "EntityManagerBaseTemplate.lpt" you'll see what I was getting at with wanting that stuff to be available to a whole templateset without having to redefine it on every template. I suppose copy/paste is good enough though. wink

Here they are: http://code.caliberweb.com/LLBLGenProManagers.zip

Chris

Can someone please explain what these "controller" templates are used for?

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 10-Dec-2004 19:38:56   

alexdresko wrote:

Can someone please explain what these "controller" templates are used for?

They generate a bunch of helper "Manager" classes which provider methods for doing usual tasks like Fetching, Saving and Deleting.

So instead of writing:


PersonEntity entity = new PersonEntity(personID);
using (DataAccessAdapter adapter = new DataAccessAdapter()){
    adapter.Fetch(entity);
}

You simply have to call:


PersonEntity entity = PersonManager.Fetch(PersonID);

It gets more helpful when you are think about related objects for example:


PrefetchPath2 prefetch = new PrefetchPath2( (int)EntityType.PersonEntity );
prefetch.Add( PersonEntity.PrefetchPathHomeAddress );
PersonEntity entity = new PersonEntity(personID);
using (DataAccessAdapter adapter = new DataAccessAdapter()){
    adapter.Fetch(entity, prefetch);
}

is replaced by:


PersonEntity entity = PersonManager.FetchWithHomeAddress(PersonID);

Something that is missing in these templates however is the ability to pass in an existing DataAccessAdapter... which would be required for transaction control.

The nice thing, is that its easily added by simply adding a contructor which takes DataAccessAdapter as a parameter and stores in a field which is accessed by the DataAdapter property of the ManageBase class.

[UPDATE] This is of course "rubbish" as the methods are static. flushed

You will have to provide overloaded methods which take a DataAccessAdapter instance as a parameter... [/UPDATE]

Marcus

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 10-Dec-2004 20:17:09   

Marcus wrote:

Something that is missing in these templates however is the ability to pass in an existing DataAccessAdapter... which would be required for transaction control.

The nice thing, is that its easily added by simply adding a contructor which takes DataAccessAdapter as a parameter and stores in a field which is accessed by the DataAdapter property of the ManageBase class.

[UPDATE] This is of course "rubbish" as the methods are static. flushed

You will have to provide overloaded methods which take a DataAccessAdapter instance as a parameter... [/UPDATE]

Marcus

This is something that I've never to date had a use for. I'll give it some thought. wink

One thing I have added today is a strongly-typed collection class that holds IPrefetchPathElement2 objects and overloads to the FetchWith* methods that accept a PrefetchPathElement2Collection for additional prefetches. This proved to be very useful today for me. YAY!!! smile Hopefully, other people will find the so too.

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 10-Dec-2004 21:15:16   

Marcus wrote:

Something that is missing in these templates however is the ability to pass in an existing DataAccessAdapter... which would be required for transaction control.

I actually adding these now... and you can have them when I'm done... simple_smile

cmartinbot wrote:

One thing I have added today is a strongly-typed collection class that holds IPrefetchPathElement2 objects and overloads to the FetchWith* methods that accept a PrefetchPathElement2Collection for additional prefetches. This proved to be very useful today for me. YAY!!! smile Hopefully, other people will find the so too.

Cool, will you be making these available also?

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 10-Dec-2004 21:46:03   

Marcus wrote:

I actually adding these now... and you can have them when I'm done... simple_smile

Cool. stuck_out_tongue_winking_eye

cmartinbot wrote:

One thing I have added today is a strongly-typed collection class that holds IPrefetchPathElement2 objects and overloads to the FetchWith* methods that accept a PrefetchPathElement2Collection for additional prefetches. This proved to be very useful today for me. YAY!!! smile Hopefully, other people will find the so too.

Marcus wrote:

Cool, will you be making these available also?

Yup smile

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 10-Dec-2004 21:50:17   

Otis,

I remember you offering to setup a Subversion repository before. Would that be possible now to accomodate ongoing development of these templates between other members? flushed

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 10-Dec-2004 21:57:11   

cmartinbot wrote:

Otis,

I remember you offering to setup a Subversion repository before. Would that be possible now to accomodate ongoing development of these templates between other members? flushed

I was going to suggest exactly the same thing... smile

swallace
User
Posts: 648
Joined: 18-Aug-2003
# Posted on: 10-Dec-2004 22:20:17   

Man, this is GREAT! Thanks, cmartinbot! I'm saving even more time (using these templates) with my timesaver tool (LLBLGen). This keeps up and I'll just go home for the day and let the tools do the work...

simple_smile

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 11-Dec-2004 10:25:42   

Hi,

The 2 updated template files which include the DataAccessAdapter overloads are available at http://www.styledesign.biz/downloads/temp/2004-12-10UpdatedTemplates.zip

These new templates produce code that compiles ok, but I have not tested the changes or the original generated code from cmartinbot.

Marcus

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Dec-2004 11:27:02   

We moved our site from our co-located server to an ISP server. The co-located server is leased and that will end april 2005 (as no important websites are running on it at the moment, our own site will move to an ISP as well), so the subversion setup is not possible I'm afraid. However I'd love to post a .zip on the 3rd party section, if the templates are generic enough to be interesting to others simple_smile (which these are simple_smile )

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 11-Dec-2004 11:40:47   

I'll set up a GotDotNet Workspace as a temporary solution... Can everyone who is interested email me directly with your email address so that I can set you up as Workspace members.

email: llblgen AT styledesign.biz

Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 11-Dec-2004 11:49:15   

rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage

**GotDotNet Workspaces**
Your request cannot be processed at this time. 
The application may be under heavy load or may be encountering an internal error. 

Will these guys ever get their act together!!!!!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Dec-2004 12:18:13   

Marcus wrote:

rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage rage

**GotDotNet Workspaces**
Your request cannot be processed at this time. 
The application may be under heavy load or may be encountering an internal error. 

Will these guys ever get their act together!!!!!

GotDotNet is the web-equivalent of hellonearth.exe

There is a workspace of llblgen code (the old DAL generator) but it was SUCH a pain to get stuff uploaded... it made sourceforge's CVS crap look brilliantly smooth.

This thread spawned some discussion here about what to do with our old leased Dell pizzabox online (the one running www.sd.nl and a couple of other sites). I now realize that it might be a good thing to have to offer to a limited group of people to have a sourcecontrol for the templates which is controlled by us and not by some 3rd party like microsoft (which has an EULA you don't want to deal with wink ).

I'll try to setup Subversion on our box within the hour to see if we can get this running. Stay tuned.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Dec-2004 15:00:51   

I'm almost done with setting up subversion, there is a little problem at the moment though: the online box is humming along fine but I accidentily closed vnc so I can't reboot it at the moment (it has to be rebooted to open the subversion tcp port) as the poweroutlet apparently isn't connected correctly to the APC online power control (the server was moved last friday) and because the vnc server is closed, I can't reconnect! (yeah, that was pretty silly wink ). rage As I've tried as much as possible to lock down the thing I can't get it to start vnc again as I can't login nor start it via a webpage I've uploaded aaaaaaargg....

They're busy with it now, but I don't know how long it will take. As soon as I can reboot the darn thing I'll continue with teh subversion setup and will let you know how to get an account and get access to the repository.

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 11-Dec-2004 15:35:15   

Otis wrote:

... because the vnc server is closed, I can't reconnect! (yeah, that was pretty silly wink ).

At least you hadn't got the ISP to open up the SQL Server port for your dynamically asssigned IP address so that you could do some major upgrades over the weekend (they don't work the weekends) and half way through (for some reason) you accidentally pull the plug on the router which causes a reboot and a new IP Address frowning

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Dec-2004 15:37:55   

Marcus wrote:

Otis wrote:

... because the vnc server is closed, I can't reconnect! (yeah, that was pretty silly wink ).

At least you hadn't got the ISP to open up the SQL Server port for your dynamically asssigned IP address so that you could do some major upgrades over the weekend (they don't work the weekends) and half way through (for some reason) you accidentally pull the plug on the router which causes a reboot and a new IP Address frowning

whoa that's also very clever wink simple_smile But let's say 'these accidents happen' wink

(my ISP isn't very fast though, still haven't heard back from them... (*@$$#@)

Frans Bouma | Lead developer LLBLGen Pro
swallace
User
Posts: 648
Joined: 18-Aug-2003
# Posted on: 11-Dec-2004 17:37:11   

One thing I want to add when it's under source control is increased support in the generated prefetchs for paging of the child collections. More overloading! Who cares if my assembly is 5 megabytes! WooHoo!

and while we're on it, there was, in another thread, some CLSA discussions. Isn't this template very close to being that already? What's the work to take it there?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 11-Dec-2004 19:08:57   

Subversion runs. I've mailed 3 people so we can test out write access.

readaccess is anonymous:

svn://www.sd.nl/LLBLGenPro

Nothing there yet, except some dirs simple_smile

(edit) I've imported the initial templates by chris with the fixes applied to it by Marcus.

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 13-Dec-2004 17:29:40   

Otis wrote:

Subversion runs. I've mailed 3 people so we can test out write access.

readaccess is anonymous:

svn://www.sd.nl/LLBLGenPro

Nothing there yet, except some dirs simple_smile

(edit) I've imported the initial templates by chris with the fixes applied to it by Marcus.

Frans... I have installed TortoiseSVN, but the Repository Browser is giving me an error when i try to connect to the

svn://www.sd.nl/LLBLGenPro

repository.

I get:


 + svn://www.sd.nl
   Error * No repository found in 'svn://www.sd.nl'

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 13-Dec-2004 17:47:09   

That's teh error you get when you specify

svn://www.sd.nl

or when you have the casing not correct. If I select Repro browser in the tortoisesvn menu and I specify:

svn://www.sd.nl/LLBLGenPro

it works... strange...

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 13-Dec-2004 18:01:42   

Otis wrote:

That's teh error you get when you specify

svn://www.sd.nl

or when you have the casing not correct. If I select Repro browser in the tortoisesvn menu and I specify:

svn://www.sd.nl/LLBLGenPro

it works... strange...

Its working now.... Strange indeed!

1  /  2