This is a migrated thread and some comments may be shown as answers.

OpenAccess validation

1 Answer 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex Suutri
Top achievements
Rank 1
Alex Suutri asked on 25 Jan 2013, 12:59 PM
Hello. I'm trying to evaluate OpenAccess ORM. I created internal interface with dataannotations and partial Bank class:
internal interface IBank
    {
        [Required(ErrorMessageResourceName = "BankNameMandatory", ErrorMessageResourceType = typeof(Resources))]
        [StringLength(50, ErrorMessageResourceName = "BankNameMaxLength",
            ErrorMessageResourceType = typeof(Resources))]
        string Name { get; set; }
 
        [Required(ErrorMessageResourceName = "BankCodeMandatory", ErrorMessageResourceType = typeof(Resources))]
        [StringLength(15, ErrorMessageResourceName = "BankCodeMaxLength",
            ErrorMessageResourceType = typeof(Resources))]
        string Code { get; set; }
 
        [StringLength(50, ErrorMessageResourceName = "BankAddressMaxLength",
            ErrorMessageResourceType = typeof(Resources))]
        string Address { get; set; }
 
        [StringLength(9, ErrorMessageResourceName = "BankExtraCodeMaxLength",
            ErrorMessageResourceType = typeof(Resources))]
        string ExtraCode { get; set; }
    }
 
     [MetadataType(typeof(IBank))]
    public partial class Bank : IDataErrorInfo, IBank
    {
         [NonSerialized]
         private readonly DataErrorInfoSupport _dataErrorInfoSupport;
 
         public Bank()
         {
             _dataErrorInfoSupport = new DataErrorInfoSupport(this);
         }
         #region IDataErrorInfo Members
 
         public string Error
         {
             get { return _dataErrorInfoSupport.Error; }
         }
 
         string IDataErrorInfo.this[string memberName]
         {
             get { return _dataErrorInfoSupport[memberName]; }
         }
 
         #endregion
 
       }

But i cannot get error. What i'm doing wrong?

1 Answer, 1 is accepted

Sort by
0
Dimitar Tachev
Telerik team
answered on 28 Jan 2013, 11:47 AM
Hi Alex,

In general one class could implement multiple interfaces that have the same properties with conflicting attributes on them. 

In this particular case it cannot be determined which are the attributes that should take precedence and for this reason using interfaces with Data Annotations is not allowed.

If it is applicable for you I suggest you to make the IBank interface an abstract class and inherit that class from the Bank one.

I hope this helps. Do not hesitate to contact us back if you need any further assistance.

Greetings,
Dimitar Tachev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
Tags
General Discussions
Asked by
Alex Suutri
Top achievements
Rank 1
Answers by
Dimitar Tachev
Telerik team
Share this question
or