예제 #1
0
        //map dataset with list of TEntity
        public static List <TEntity> MapDataWithList <TEntity>(DataSet data) where TEntity : class, new()
        {
            //required class for mapping TEntity and list for result
            List <TEntity>            objectList = new List <TEntity>();
            DataNamesMapper <TEntity> mapper     = new DataNamesMapper <TEntity>();
            //get table name from table name attribute
            string tableName = AttributeHelper.GetTableName <TEntity>();

            //find needed table and map data
            foreach (DataTable table in data.Tables)
            {
                if (table.TableName == tableName)
                {
                    objectList = (List <TEntity>)mapper.Map(table);
                }
            }

            return(objectList);
        }