-
-
Save hadoan/2f56c0e8edb94b5786fadb675b8eb9f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataMapper<TEntity, TIDType, TLinqEntity> : IDataMapper<TEntity, TIDType, TLinqEntity> | |
where TEntity : AbstractBaseData<TIDType> | |
where TLinqEntity : EntityObject | |
{ | |
public IList<TEntity> GetEntitiesFromEF(IList<TLinqEntity> linqEntities) | |
{ | |
Mapper.Initialize | |
( | |
cfg => | |
{ | |
cfg.CreateMap<TLinqEntity, TEntity>(); | |
cfg.CreateMap<TEntity, TLinqEntity>(); | |
} | |
); | |
var listOfEntities = Mapper.Map<IList<TLinqEntity>, IList<TEntity>>(linqEntities); | |
return listOfEntities; | |
} | |
} | |
//Hàm GetAll sẽ có dạng như sau: | |
public virtual IList<TEntity> GetAll() | |
{ | |
var entities = this.SelectAll(); | |
var listOfEntites = Factory.CreateDataMapper<TEntity, TIDType, TLinqEntity>().GetEntitiesFromEF(entities); | |
return listOfEntites; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment