Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting Defaults
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01423203
Message ID:
01423244
Vues:
33
Hey, great it worked!

To recap (for my own benefit as much as anyone else's), in order to add default values to an existing business object who's default values weren't created when you created them with the MM.Net Business Layer Generator:

1. In the Entity.Partial.cs file, create a new default values class, eg.
public class SeminarFeeDefaultValues
    {
        public int iEvSemId = 0;

        public SeminarFeeDefaultValues(int iEventId)
        {
            this.iEvSemId = iEventId;
        }
2. In the same file, in the main class definition for the entity, add an override method for HookSetDefaultValues, eg.
  protected override void HookSetDefaultValues(SeminarFeeEntity entity)
        {
            if (this.DefaultValues != null)
            {
                // Store the dynamic default values via the entity object
                entity.numEventID = Defaults.iEvSemId;
            }
        }
3. Also in the same file, add a Defaults property
 /// <summary>
        /// Default values object
        /// </summary>
        public virtual SeminarFeeDefaultValues Defaults
        {
            get { return (SeminarFeeDefaultValues)this.DefaultValues; }
            set { this._defaults = value; }
        }
        private SeminarFeeDefaultValues _defaults;
4. Now when you create a new Entity (or new Row in a dataset where I'm using it), be sure to use the overloaded method and seed the default value
 // Add a new row to the DataSet
        oFee.NewRow(ds, oFee.TableName, new SeminarFeeDefaultValues(iEventId));
That does it.

And Kevin, let me add that the MM.Net Developer's Guide is one of the best resources for .NET programming I've encountered. It's really really good.

Thanks!

Eric



>Eric,
>
>>protected override void HookSetDefaultValues(OrderDetailEntity entity)
>>{
>> if (this.DefaultValues != null)
>> {
>> // Store the dynamic default values via the entity object
>> entity.OrderID = Defaults.OrderID;
>> }
>>}
>>
>
>The Defaults property is generated by the Business Layer Generator -- only if you have dynamic default values (vs,. hard-coded values). It looks like this on the OrderDetail business object:
>
>
/// <summary>
>/// Default values object
>/// </summary>
>public virtual OrderDetailDefaults Defaults
>{
>	get { return (OrderDetailDefaults)this.DefaultValues; }
>	set { this._defaults = value; }
>}
>private OrderDetailDefaults _defaults;
>
>Best Regards,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform