A custom property in a partial class does not exist AFTER it is sent to the client using WCF data services

So, I have an Event class that is generated from the Enitity Framework, I extended what it generated in partial, for example:

public partial class Event { [DataMemberAttribute()] public EventDate CurrentEventDate { get; set; } } 

When I use the ON THE SERVER custom property, this is good, for example:

  [WebGet] public IQueryable<Event> EventsOn(string date) { var to Return = // Get my events here toReturn.ToList().ForEach(ev => ev.CurrentEventDate = ev.EventDates.Where( evd => evd.StartDateTime.Date <= qDate.Date && evd.EndDateTime >= qDate.Date).Single()); return toReturn.AsQueryable(); } 

But when I try to look at this object in Javascript, it tells me that:

Error: "CurrentEventDate" is null or not an object

How can I get custom properties after they have been sent by cable?

+4
source share
2 answers

Make sure that both partial class definitions are in the same namespace. Otherwise, the compiler will turn them into two separate classes and will not warn you.

+1
source

Just a long shot - EventDate seems to be a normal time. If so, have you decorated it with the Serializable and DataContract attributes (and its properties with the DataMember attribute)?

0
source

All Articles