Class PersistableAttribute
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:
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;
}
...
}
Namespace: Neon.ModelGen
Assembly: Neon.Common.dll
Syntax
[AttributeUsage(AttributeTargets.Interface)]
public class PersistableAttribute : Attribute
Properties
GetKeyArgs
This property combined with GetKeyString is used
to generate a public static string GetKey(...)
method.
See the class remarks for more information.
Declaration
public string GetKeyArgs { get; set; }
Property Value
Type | Description |
---|---|
string |
GetKeyString
This property combined with GetKeyArgs is used
to generate a public static string GetKey(...)
method.
See the class remarks for more information.
Declaration
public string GetKeyString { get; set; }
Property Value
Type | Description |
---|---|
string |