Extending your manager templates

Posts   
 
    
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 09-Jun-2005 15:15:54   

I have added 4 new methods to my ManagerBase that you might find useful.

Here is the code that ends up being generated in the ManagerBase:


        #region Unit Of Work
        public void CommitUnitOfWork(UnitOfWork2 uow)
        {
              CommitUnitOfWork(uow,true);
        }

        public virtual void CommitUnitOfWork(UnitOfWork2 uow, bool autoCommit)
        {
              using (DataAccessAdapter adapter = new DataAccessAdapter())
              {
                    uow.Commit(adapter, autoCommit);
              }
        }
        #endregion

        #region GetDBCount
        protected virtual int GetDbCount(IEntityFields2 fields, RelationPredicateBucket filter, 
            GroupByCollection groupBy, bool allowDuplicates)
        {
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                return adapter.GetDbCount(fields, filter, groupBy, allowDuplicates);
            }
        }

        protected virtual int GetDbCount(IEntityCollection2 collection, RelationPredicateBucket filter, 
            GroupByCollection groupBy)
        {
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                return adapter.GetDbCount(collection, filter, groupBy);
            }
        }
        #endregion

My methods are not static so if you want to use this code, you will need to add the static keyword to methods. You can put this code into the ManagerBase lpt file to create the methods above.

Enjoy.

erichar11
User
Posts: 268
Joined: 08-Dec-2003
# Posted on: 09-Jun-2005 16:17:57   

Hey DevilDog, just curious as to why you didn't makes these static. Any particular reason?

By the way, I'm using your manager templates in my current project. Thanks. They work very well.

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 09-Jun-2005 16:46:49   

I took the manager templates defined by cmartinbot and made them all instance specific. I did this because I have a framework that uses COM+ controllers to create instances of entity managers and wraps the transactions of entity managers into COM+ transaction management. I have found that using static members in COM+ acts funny sometimes, so I made all of my methods instance specific.

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 09-Jun-2005 22:51:21   

Cool! simple_smile

Thanks man. I was going to add UnitOfWork support next.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 10-Jun-2005 09:46:39   

simple_smile Have you checked them into subversion?

Frans Bouma | Lead developer LLBLGen Pro
Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 11-Jun-2005 14:23:11   

Otis wrote:

simple_smile Have you checked them into subversion?

No because I am a slacker flushed It is on the never ending list of things to do though smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 11-Jun-2005 15:10:56   

Devildog74 wrote:

Otis wrote:

simple_smile Have you checked them into subversion?

No because I am a slacker flushed It is on the never ending list of things to do though smile

Heh, you too have such a list? wink

Frans Bouma | Lead developer LLBLGen Pro
steele
User
Posts: 4
Joined: 26-Apr-2005
# Posted on: 24-Jun-2005 20:35:57   

Before I spend the next several hours doing this...

Has anyone already converted/ported these manager classes to VB?

I need to have the codespit in VB for a client and can't just include the C#

Anyway, both languages should be available and I am willing to do it if no one else has already done so.

Steele Price

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 24-Jun-2005 20:58:22   

They're only producing C# at the moment... I'm not aware of anyone porting them to VB.NET. Would be a great addition! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
steele
User
Posts: 4
Joined: 26-Apr-2005
# Posted on: 27-Jun-2005 22:18:39   

Otis wrote:

They're only producing C# at the moment... I'm not aware of anyone porting them to VB.NET. Would be a great addition! simple_smile

Am I missing something in Template Studio...

During this conversion, whenever I open a Template in Template Studio it Defaults the Logic Language to LogicVBDotNet

I want to keep the LogicCSharp and just change the Main Language to VBDotNet.

This makes it very annoying to edit these since it is autoconverting all the cases in the Ligoc portion and won't change it back.

I have to go back and change all the Template Logic when I shouldn't have to.

I have been looking around preferences and template config setting and can't find a way to stop this behavior.

I'll get these finished today hopefully, but every time I have to reopen a template it is converting all the logic and I just had to stop using TS as an editor after the initial conversion.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 28-Jun-2005 10:22:19   

steele wrote:

Otis wrote:

They're only producing C# at the moment... I'm not aware of anyone porting them to VB.NET. Would be a great addition! simple_smile

Am I missing something in Template Studio...

During this conversion, whenever I open a Template in Template Studio it Defaults the Logic Language to LogicVBDotNet

I want to keep the LogicCSharp and just change the Main Language to VBDotNet.

This makes it very annoying to edit these since it is autoconverting all the cases in the Ligoc portion and won't change it back.

I have to go back and change all the Template Logic when I shouldn't have to.

I have been looking around preferences and template config setting and can't find a way to stop this behavior.

I'll get these finished today hopefully, but every time I have to reopen a template it is converting all the logic and I just had to stop using TS as an editor after the initial conversion.

This selection is based on the target language in the templateset definition. So if you want to keep it as CSharp, keep that targetlanguage set to C# till you're done template editing simple_smile .

Frans Bouma | Lead developer LLBLGen Pro
steele
User
Posts: 4
Joined: 26-Apr-2005
# Posted on: 28-Jun-2005 19:25:12   

Yep, that fixed the default loading, thanks.

You may consider adding a new config Element, such as:

<logicLanguage>C#</logicLanguage>

Then it could map to the correct pairing. Because even when these are done, it's going to default to VB and convert them if anyone opens them to edit or tweak them.

I think I may have several circumstances when I have C# Logic and VB Main Language

It makes sense to have the Logic the same in dual language templates right?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39786
Joined: 17-Aug-2003
# Posted on: 29-Jun-2005 11:29:48   

steele wrote:

Yep, that fixed the default loading, thanks.

You may consider adding a new config Element, such as:

<logicLanguage>C#</logicLanguage>

Then it could map to the correct pairing. Because even when these are done, it's going to default to VB and convert them if anyone opens them to edit or tweak them.

I think I may have several circumstances when I have C# Logic and VB Main Language

It makes sense to have the Logic the same in dual language templates right?

I first wanted to add that, though it would cause problems for existing template set definitions, which then didn't deserialize well... So I decided to drop that for now, as the targetlanguage is only used for TDL, not by .lpt. So if you set it to C# if you have your templates written in C#, it doesn't matter if your output language is VB.NET or HTML or whatever. simple_smile

Frans Bouma | Lead developer LLBLGen Pro