New Posts New Posts RSS Feed: [Solved] Deletion Guard
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[Solved] Deletion Guard

 Post Reply Post Reply
Author
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Topic: [Solved] Deletion Guard
    Posted: 12-Sep-2007 at 7:11pm
Great!  Deletion guard works beautifully.  Powerful stuff!
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 7:05pm

I did read your response on the other post.  Many thanks!!  I am in the object mapper right now, setting the base classes for my objects.  The BaseEntity thing certainly is the way to go...obviously!

Regenerating the objects, now.
 
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 6:59pm
Let the object mapper add the inheritance from BaseEntity.  That way it will remember and not overwrite it when you regenerate the model.
 
Then just be sure BaseEntity inherits from CommonEntity.
 
BaseEntity gives you a place to add your common entity behavior.
 
See my response to your earlier post as well at http://www.ideablade.com/forum/forum_posts.asp?TID=369
 
Sorry not to respond sooner.
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 6:46pm
Ahhhhhh...this is not good.  My objects, created by the object mapper tool, skip the BaseEntity and the CommonEntity and inherit directly from Entity.  I had to manually add the inheritance to the BaseEntity to the "public abstract partial class" for the datarow.  That item was buried a bit.
 
Should I even be playing around in the datarow class file since it could be overwritten with the next update to the model project?
 
In the words of Barbarino:  I am so confused.  Confused
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 6:29pm
Nope.  Haven't checked.  However, this leads me to another post that I made:  http://www.ideablade.com/forum/forum_posts.asp?TID=369.  In it I asked if the object mapper would account for the CAB structure.  It obviously does not.  But, will it?  One day?
 
I will see about altering the inheritance, then trying again.  Thanks for the response!
 
Bill
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 4:53pm
Are you sure your entity class is inheriting (directly or indirectly) from IdeaBlade.Common.EntityModel.CommonEntity?
 
Bill J.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 2:34pm
I added this:
 
/// <summary>Get the displayable name of this object instance (e.g., "Nancy Davolio").</summary>
/// <remarks>Typically useful in validation messages.</remarks>
[BindingBrowsable(false)]
public override string EntityInstanceName { get { return CustName; } }
 
It didn't help.  I got the same kind of build error...no suitable method found to override (EntityInstanceName).  I must not have the proper reference setup somewhere.


Edited by Linguinut - 12-Sep-2007 at 2:36pm
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 12-Sep-2007 at 2:01pm
I mimicked the deletion guard code in one of my business objects:
 
/// <summary>Get if allowed to delete this customer.</summary>
/// <remarks>Don't permit delete of customer with orders.</remarks>[Bindable(false)]
[
BindingBrowsable(false)]
public override bool AllowDelete
{
   
get
   
{
       
if (SalesOrderMasters.Count > 0)
        {
// has orders...do not delete
           
return false;
        }
return true;
    }
}
 
Please note that the override throws an exception stating that there is nothing to override (in my CustomerMaster object?).  If I remove the override, then it builds and the app runs.  I did the same on another object.  Here is the message I get when I click the delete button from the navigator:
 
"Are you sure that you want to delete 'MyCompany.MyNamespace.Model.MyObject'?"
 
Whoa!  Scary!  Not quite what I want to do.  I will dig into the code a bit more to find out what is going on, but a quick response here from "someone in the know" would move things along.
 
So, two questions: 
1)  Do I need the override in the deletion guard code?
2)  How are the strings handled in the actual delete code?
 
Thanks,
Bill
 


Edited by Linguinut - 12-Sep-2007 at 7:12pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down