I am having a base model and a view model derived from it.
Base Model
public class Feed
{
public int Id { get; set; }
public string Name { get; set; }
public string Url { get; set; }
}
Derived Model
public class FeedViewModel : Feed
{
public bool EditMode { get; set; }
}
Data Access Layer
public Feed GetFeed(){
--db code to retreive all feed
}
Controller
public FeedController : Controller
{
public ActionResult Index()
{
var data = DAL.GetFeed();
var model = new FeedViewModel{ EditMode = true };
model.Id = data.Id;
model.Name = data.Name;
model.Url = data.Url; //This is working
//But i dont want like this, coz i cant reassign all the proerties again. Is there any other easy way like this
model = (FeedViewModel)data;
}
}
I dont want to reassign all the properties values again to derived model. Instead i am looking for any other easy way? Any ideas?