views:

72

answers:

2

So I have an Event class which is generated from Enitity Framework, I have extended what it generated in a partial like so:

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

When I use the custom property ON THE SERVER it's fine, 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 and look at this object in Javascript, it tells me that:

Error: 'CurrentEventDate' is null or not an object

How can I have custom properties show up after they've been sent down the wire?

+1  A: 

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

Timwi
Yup I already explicity matched the namespaces, thanks for the check though.
Tarks
A: 

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

VinayC
Thanks for the idea, but EventDate is a class generated from the Entity Framework so it's already got all the attributes.
Tarks
A suggestion - you can use Firefox or Fiddler and check the service response - that will at least tell you whether the problem lies - server side serialization or client side deserialization.
VinayC