예제 #1
0
        public TEntity Map(DataRow row, TEntity entity)
        {
            var columnNames = row.Table.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToList();
            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);
        }
예제 #2
0
        public IEnumerable <TEntity> Map(DataTable table)
        {
            List <TEntity> entities    = new List <TEntity>();
            var            columnNames = table.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToList();
            var            properties  = (typeof(TEntity)).GetProperties()
                                         .Where(x => x.GetCustomAttributes(typeof(DataNamesAttribute), true).Any())
                                         .ToList();

            foreach (DataRow row in table.Rows)
            {
                TEntity entity = new TEntity();
                foreach (var prop in properties)
                {
                    PropertyMapHelper.Map(typeof(TEntity), row, prop, entity);
                }
                entities.Add(entity);
            }
            return(entities);
        }