Ejemplo n.º 1
0
        } // end method



        private T CreateObject<T>(IRecord record) where T : new() {
            T obj = new T();
            var type = typeof(T);
            var mirror = mirrorCache[type];
            foreach (var column in record.Keys) {
                var propertyName = GetMappedProperty(type, FormatColumnName(column));
                var prop = mirror.GetProperty(propertyName, CaseInsensitiveBinding);
                if (prop == null)
                    continue;

                var val = record[column];
                if (val != null) {
                    var propMirror = mirrorCache[prop.PropertyType];
                    if (!propMirror.IsAssignableFrom(val.GetType()))
                        val = SystemTool.SmartConvert(val, prop.PropertyType);
                } // end if
                prop.SetValue(obj, val, null);
            } // end for
            return obj;
        } // end method