Click or drag to resize

PersistableAttribute Class

Used to customize the database related code generated for the tagged data model interface.

By default, a public static string GetKey(param object[] args) method is included in generated entity classes so that a database key for a specific entity can be easialy obtained. This method simply generates a string by calling ToString on all of arguments or using "NULL" for null values which each of these being separated by a single colon and then prepending the entire thing with the entity type. The generated code will look something like this:

C#
public class PersonEntity : Entity<Person>
{
    public static string GetKey(params object[] args)
    {
        if (args.Length == 0)
        {
            throw new ArgumentException("At least one argument is expected.");
        }

        var key = "entity-type::";

        for (int i=0; i $lt; args.Length; i++)
        {
            var arg = args[i];

            if (i > 0)
            {
                key += ":";
            }

            key += arg != null ? arg.ToString() : "NULL";
        }

        return key;
    }

    ...
}
Inheritance Hierarchy
SystemObject
  SystemAttribute
    Neon.ModelGenPersistableAttribute

Namespace:  Neon.ModelGen
Assembly:  Neon.Common (in Neon.Common.dll) Version: 2.14.0
Syntax
public class PersistableAttribute : Attribute

The PersistableAttribute type exposes the following members.

Constructors
  NameDescription
Public methodPersistableAttribute
Initializes a new instance of the PersistableAttribute class
Top
Properties
  NameDescription
Public propertyGetKeyArgs
This property combined with GetKeyString is used to generate a public static string GetKey(...) method. See the class remarks for more information.
Public propertyGetKeyString
This property combined with GetKeyArgs is used to generate a public static string GetKey(...) method. See the class remarks for more information.
Public propertyTypeId
When implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute.)
Top
Methods
  NameDescription
Public methodEquals
Returns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from Attribute.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsDefaultAttribute
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute.)
Public methodMatch
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
See Also