Finding .Save()

Posts   
 
    
Rob
User
Posts: 54
Joined: 17-Sep-2004
# Posted on: 04-Feb-2010 04:47:44   

Hello!

I wonder if there is a way to find all references to an entity class' .Save() method. My project has grown faily big now and I need to find all references to where I save a particular class. If I right click on .Save() someplace where I use it and go 'Go to definition' I end up on a page called EntityBase [from metadata]. When I try and right-click .Save() there it does not give the option 'Find All References'.

If I use the pbject browser it does not show the .Save() method for my entity class. I can only find it in the EntityBase class and if I 'Find All References' there then it shows me the references to ALL save mthods for ALL classes. I have over 200 classes so it shows my 585 matches, so it is not very helpful to look through.

Is there a simple way to find all references to the generated .Save() method for an EntityClass?

Any help will be appreciated,

!Rob

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 04-Feb-2010 10:00:04   

Seems to me like a Visual Studio issue, rather than LLBLGen issue.

A technical trick would be to use Method Hiding on the entity class, and set the access modifier to private.

When you compile, the compiler will generate errors for all lines where Save was called on your entity.

Now that you know where the Save calls where made, afterwards you should remove the method you added to hide the base class one.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 04-Feb-2010 10:39:23   

shift-F12 in vs.net, it will reveal all usages of the member the cursor is at.

Frans Bouma | Lead developer LLBLGen Pro
Rob
User
Posts: 54
Joined: 17-Sep-2004
# Posted on: 04-Feb-2010 11:05:24   

Hi guys!

Shift-F12 reveals all the references to .Save() in the base class. That is all the .Save() methods in all my 200+ entity classes. Currenly I call all those from 585 places.

I just want the calls to my BizEventEntity.Save() method, where obviously BizEvent is a table in my db.

Walaa, I am sorry but I don't really follow your reasoning. Since the Save() method sits in the base class wouldn't that just do the same thing.

In an earlier version of LLBLGen this was possible, I guess perhaps there was a Save() method per entityclass or something, and in a later version that was moved to the base class?

Anyway, if it is not possible I guess I have to search through all 585 calls to .Save(). I am just a tad worried that I might miss one or two. What I want to do is to replace all those calls to my own .Save() where I can control a few things before saving.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 04-Feb-2010 11:08:01   

My theory was:

You can override the base class save method inside BizEventEntity, using private and new keywords. This will hide the base class method from all the callers. So the compiler would yell about the Save() calls being made to the BizEventEntity instances.

Rob
User
Posts: 54
Joined: 17-Sep-2004
# Posted on: 04-Feb-2010 11:19:07   

I feel that you are probably on to something here Walaa. I added the below Save method within my own partial BizEventEntity class.

The problem is that the code compiles just fine. I get no errors and still cannot find my references.

namespace sevenG.BusinessLogic.EntityClasses
{
    public partial class BizEventEntity : CommonEntityBase, ISerializable
    {
        private new bool Save()
        {
            return false;
        }


Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 04-Feb-2010 11:57:56   

You forgot the override keyword.

namespace sevenG.BusinessLogic.EntityClasses
{
    public partial class BizEventEntity : CommonEntityBase, ISerializable
    {
        private override new bool Save()
        {
            return false;
        }
    }
}
Rob
User
Posts: 54
Joined: 17-Sep-2004
# Posted on: 04-Feb-2010 14:37:06   

Thanks, I tried but get this:

Error 1 'sevenG.BusinessLogic.EntityClasses.BizEventEntity.Save()': virtual or abstract members cannot be private

Error 2 A member 'sevenG.BusinessLogic.EntityClasses.BizEventEntity.Save()' marked as override cannot be marked as new or virtual

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-Feb-2010 21:57:46   

About the only other option I can think of is to use the LLBLGen sourcecode to build a debug version of the SupportClasses dll with the entity.save method renamed to something else. This will then cause the compile of your project to choke on all the existing .Save methods.

Not to rub salt into the would, but this is another significant benefit of using the Adapter model. With a carefully designed DataAccess layer performing all of your data operations, your .Save methods would be in at most 2 or 3 methods in a single class simple_smile

Matt

Rob
User
Posts: 54
Joined: 17-Sep-2004
# Posted on: 04-Feb-2010 23:50:43   

In this case I will just bite the bullet. It would take longer to start fiddling with LLBLGen source code.

Regarding adapter. I have admittedly not looked much at how it is implemented. When I started using LLBLGen for this project in 2004 it looked as if the extra work required was not justified by any benefits I needed. Since then things may have changed.

Also, I have 263 entity classes and 585 references to Save(). That is on average just over 2 per class...