I have a POCO Class with name TaskWeek in my business layer and in my presentation layer I defined a new Class:
public class TaskWeekUI : TaskWeek
{
public DateTime EndDate { get; set; }
public string PersianEndDate
{
get
{
return UIUtility.ConvertToPersianDate(EndDate);
}
}
}
Then I have a method public void Save(List taskweeks) , When I want to call this method I convert a List and call this method:
using (TaskWeekDA twa = new TaskWeekDA())
{
IEnumerable<TaskWeek> tw = MainObjects.twUi.OfType<TaskWeek>();
twa开发者_Python百科.Save(tw.ToList());
}
but instead to save I've got this error : Mapping and metadata information could not be found for EntityType
Thanks
Instead of inheriting from TaskWeek is it possible for you to write your methods in a partial class?
For example, write a TaskWeek.part.cs like:
//namespace has to be the same as TaskWeek that your model generated
public partial class TaskWeek
{
public DateTime EndDate { get; set; }
public string PersianEndDate
{
get
{
return UIUtility.ConvertToPersianDate(EndDate);
}
}
}
This way the EF has info about the class type, and you have the same functionality as with inheriting (that is, if you're not using inheritance for some other stuff).
精彩评论