Exemple #1
0
        public TEntity Map(DataRow row, TEntity entity)
        {
            var properties = (typeof(TEntity)).GetProperties()
                             .Where(x => x.GetCustomAttributes(typeof(DataNamesAttribute), true).Any())
                             .ToList();

            foreach (var prop in properties)
            {
                PropertyMapHelper.Map(typeof(TEntity), row, prop, entity);
            }

            return(entity);
        }
Exemple #2
0
        public IEnumerable <TEntity> Map(DataTable table)
        {
            var entities   = new List <TEntity>();
            var properties = (typeof(TEntity)).GetProperties()
                             .Where(x => x.GetCustomAttributes(typeof(DataNamesAttribute), true).Any())
                             .ToList();

            foreach (DataRow row in table.Rows)
            {
                var entity = new TEntity();

                foreach (var prop in properties)
                {
                    PropertyMapHelper.Map(typeof(TEntity), row, prop, entity);
                }

                entities.Add(entity);
            }

            return(entities);
        }