I have a class with looks like this:
[DataContract] public class TestBatchWithHistoryResult { [Key] [DataMember] public int Id { get; set; } [DataMember] public string Name { get; set; } [DataMember] public string Description { get; set; } [DataMember] public string LastRequestedBy { get; set; } [DataMember] public DateTime? LastRun { get; set; } [DataMember] public Collection<string> LastConfigurations { get; set; } [DataMember] public TestBatch Entity { get; set; } } When I build the website and Silverlight project and find that the Entity property is not created in the "auto-generated" code on the Silverlight side, but all the other properties are present.
What could be preventing the Entity property from being created?
Thanks
Michael
Answer: 1
If the data contract is not referenced by any of your services, it will not be present. Only referenced data contracts are generated. If it is not referenced but it should be (ie if it is a type inherited from one that is returned, and will be returned at some point) use the ServiceKnowTypeAttribute to declare it at the beginning of you service contract.
Answer by Paul T Davies for Custom class with an entity and RIA Services/SilverlightAnswer: 2
For child entities to be created on the client-side, you need to have a service method exposing that entity type on the server side, e.g:
public IQueryable<TestBatch> GetTestBatches(){} And you also need to have the Include attribute on the property:
[Include] public TestBatch Entity {get; set;} Answer by Tevin for Custom class with an entity and RIA Services/Silverlight
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog