Example #1
0
        /// <summary>
        /// Creates a column property mapping for the specified
        /// data table and entity
        /// </summary>
        /// <param name="sourceTable"></param>
        /// <param name="entityType"></param>
        /// <returns></returns>
        public static ColumnPropertyMap Create(DataTable sourceTable, Type entityType)
        {
            ColumnPropertyMap         map        = new ColumnPropertyMap();
            List <EntityPropertyInfo> properties = EntityInfoCache.Get(entityType);

            foreach (DataColumn column in sourceTable.Columns)
            {
                foreach (EntityPropertyInfo property in properties)
                {
                    if (property.IsEntity || property.IsEntityList)
                    {
                        continue;
                    }

                    if (property.EffectiveDataColumnName.ToUpper().Trim() == column.ColumnName.ToUpper().Trim())
                    {
                        map.Add(column.ColumnName, property);
                    }
                }
            }
            return(map);
        }