I have a domain data model which returns a class such as the following:
public class ZombieDeath
{
public virtual int ZombieId {get;set;}
public virtual FatalHit {get;set;}
}
public class FatalHit
{
public virtual int HitId {get;set;}
public virtual string Zone {get;set;}
public virtual string Weapon {get;set;}
}
When passing this data back to my grids, I've read that is best to always return data to the views in a flattened format. So I have the following class that represents a grid row:
public class ZombieDeathRow
{
public virtual int ZombieId {get;set;}
public virtual int HitId {get;set;}
public virtual string Zone {get;set;}
public virtual string Weapon {get;set;}
}
So, when this is rendered, I just call Model.Weapon
, instead of Model.FatalHit.Weapon
. It does make the view's code much nicer to read, but it's obviously an additional layer of work due to the mapping required.
Is this really a good way of working, or just a waste of time?