search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Problem to load events from list of self defined objects instead of EF6 object

Asked by Oliver
9 years ago.

Hello,

I am evaluating Scheduler for MVC for project. I am able to load the events from the EntityFramework table with this (shortened) code in the overridden OnFinish() method:

Events = ctx.RMSRequest.Where(r => r.AssignedDate != null && r.NegotiatedDeadline != null && (r.NegotiatedDeadline > start || r.AssignedDate < end)).ToList();

If I change it to load only some of the fields into a defined object with the following code:
Events = ctx.RMSRequest.Where(r => r.AssignedDate != null && r.NegotiatedDeadline != null && (r.NegotiatedDeadline > start || r.AssignedDate < end)).Select(r => new DayPilotEvent()
{
SysId = r.SysId,
AssignedDate = (DateTime)r.AssignedDate,
NegotiatedDeadline = (DateTime)r.NegotiatedDeadline,
ShortDescription = r.ShortDescription,
AssignedToSysId = r.AssignedToSysId
})
.ToList();

then I get the message that the object DayPilotEvent does not contain a property "AssignedDate".

The object is defined with:

public class DayPilotEvent
{
public string SysId;
public DateTime AssignedDate;
public DateTime NegotiatedDeadline;
public string ShortDescription;
public string AssignedToSysId;
}

Can anyone see what I am doing wrong here? Any hint will be apreciated.

Answer posted by Dan Letecky [DayPilot]
9 years ago.

It might be necessary to define the object items as properties rather than simple fields:

public class DayPilotEvent 
{ 
  public string SysId { get; set; }
  public DateTime AssignedDate { get; set; } 
  public DateTime NegotiatedDeadline { get; set; }
  public string ShortDescription { get; set; }
  public string AssignedToSysId { get; set; }
}

Let me know if it didn't help.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.