开发者

Custom property in partial class doesn't exist AFTER it's sent to client using WCF Data Services

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 te开发者_如何学JAVAlls 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?


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.


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)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜