Here is what i would like to have / do:
Step 1 (Create model)
in my template i get info from the entity to add attributes
[Display(Name = "<[EntityFieldName]>", ResourceType = typeof(Resources.Resources))]
<[If Not IsNullable]>[Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "<[EntityFieldName]>_Required")]<[EndIf]>
<[If IsStringField]>[StringLength(<[FieldMaxLength]>, ErrorMessageResourceName = "<[EntityFieldName]>_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
i can create this
public class CustomerModel
{
[Display(Name = "FirstName", ResourceType = typeof(Resources.Resources))]
[Required(ErrorMessageResourceName = "FirstName_Required", ErrorMessageResourceType = typeof(Resources.Resources))]
[StringLength(255, ErrorMessageResourceName = "FirstName_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
public string FirstName { get; set; }
[Display(Name = "Surname", ResourceType = typeof(Resources.Resources))]
[Required(ErrorMessageResourceName = "Surname_Required", ErrorMessageResourceType = typeof(Resources.Resources))]
[StringLength(255, ErrorMessageResourceName = "Surname_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
public string Surname { get; set; }
}
So far so good.
Step 2: (add custom content)
Know i would like to add this with llblgen generation
(i know that we can use of partial classes here.)
public string GetFullName()
{
return string.Format("{0} {1}", FirstName, Surname);
}
Step 3: (add new field email)
[Display(Name = "EmailAddress", ResourceType = typeof(Resources.Resources))]
[Required(ErrorMessageResourceName = "EmailAddress_Required", ErrorMessageResourceType = typeof(Resources.Resources))]
[StringLength(255, ErrorMessageResourceName = "EmailAddress_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
public string EmailAddress { get; set; }
but after generation i would like to add custom email validation attribute.
[RegularExpression(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$", ErrorMessageResourceName = "EmailAddress_Regex", ErrorMessageResourceType = typeof(Resources.Resources))]
But can you generate code each step with llblgen with parts that are custom added.
public class CustomerModel
{
[Display(Name = "FirstName", ResourceType = typeof(Resources.Resources))]
[Required(ErrorMessageResourceName = "FirstName_Required", ErrorMessageResourceType = typeof(Resources.Resources))]
[StringLength(255, ErrorMessageResourceName = "FirstName_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
public string FirstName { get; set; }
[Display(Name = "Surname", ResourceType = typeof(Resources.Resources))]
[Required(ErrorMessageResourceName = "Surname_Required", ErrorMessageResourceType = typeof(Resources.Resources))]
[StringLength(255, ErrorMessageResourceName = "Surname_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
public string Surname { get; set; }
[Display(Name = "EmailAddress", ResourceType = typeof(Resources.Resources))]
[Required(ErrorMessageResourceName = "EmailAddress_Required", ErrorMessageResourceType = typeof(Resources.Resources))]
[StringLength(255, ErrorMessageResourceName = "EmailAddress_StringLength", ErrorMessageResourceType = typeof(Resources.Resources))]
[RegularExpression(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$", ErrorMessageResourceName = "EmailAddress_Regex", ErrorMessageResourceType = typeof(Resources.Resources))]
public string EmailAddress { get; set; }
public string GetFullName()
{
return string.Format("{0} {1}", FirstName, Surname);
}
}
Is this possible or are these limitations of LLBLGen.
If there is an other way to get this result please let me know .