public abstract class Entity : IEntity
{
[Key]
public virtual int Id { get; set; }
}
public class City:Entity
{
public string Code { get; set; }
}
public class BaseViewModel:IBaseViewModel
{
public int Id { get; set; }
}
public class CityModel:BaseViewModel
{
public string Code { get; set; }
}
my domain and view classes...
and
for mapping extension
public static TModel ToModel<TModel,TEntity>(this TEntity entity)
where TModel:IBaseViewModel where TEntity:IEntity
{
return Mapper.Map<TEntity, TModel>(entity);
}
and i am using like below
City city = GetCity(Id);
CityModel model = f.ToModel<CityModel, City>();
but its long
can i write it like below?
City city = GetCity(Id);
CityModel model = f.ToModel();
is that possible?