How to modify the constructor function of one class?
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



How to modify the constructor function of... Expand / Collapse
Author
Message
Posted 2010-03-28 04:31:43
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
I want to set the attribute default value of the class when the class is created,how should I do?
If I modify the (class name).eco.cs file,when I regenerate code ,the code which I add will be lost.
Please help me.
thank you!
Post #5057
Posted 2010-03-29 04:19:26


Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 2011-11-23 02:03:59
Posts: 80, Visits: 730
Assuming you're using Eco5, you can make use of the ObjectCreated partial method, e.g.

public partial class MyEcoClass
{
partial void ObjectCreated()
{
this.GUID = Guid.NewGuid();
}
}
Post #5062
Posted 2010-03-29 05:55:28
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35, Visits: 260
thank you.
Post #5063
Posted 2010-03-29 09:49:58
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230, Visits: 1 382
For most attribute types, you can also set the initial value directly in the model (in the properties window), but setting a new guid I think has to be done with the partial ObjectCreated-method.



/Jonas Hogstrom [CapableObjects]
Post #5068
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: HansKarlsen, Jonas Hogstrom, PeterMorris

Permissions Expand / Collapse

All times are GMT +1:00, Time now is 9:31

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0,172. 9 queries. Compression Disabled.