Reputation: 13
I'm using silverlight-enabled wcf service and entity framework for my silverlight business applicaiton. But there is no auto generated metadata class for the entities. So I can't easily add validations for the entities using DataAnnotations such as [Required], [ReadOnly(true)]... I create a metadata class for the entities and here is the code on the server side:
[MetadataTypeAttribute(typeof(SAMPLE.SAMPLEMetadata))]
public partial class SAMPLE
{
internal sealed class SAMPLEMetadata
{
private SAMPLEMetadata()
{
}
[Required]
[ReadOnly(true)]
public string SERIALNO { get; set; }
}
}
and here is the code on the client side, which is in the service reference forlder and under the servicereference, the file name is Reference.cs:
[System.Runtime.Serialization.DataMemberAttribute()]
public string SERIALNO {
get {
return this.SERIALNOField;
}
set {
if ((object.ReferenceEquals(this.SERIALNOField, value) != true)) {
this.SERIALNOField = value;
this.RaisePropertyChanged("SERIALNO");
}
}
}
So there is no DataAnnotaions generated like [Required]... And the Validations of course never work. I don't know how to add Validations using metadata class for silverlight-enabled wcf and entity framework. Can some one help me about this?
Upvotes: 0
Views: 297