コード例 #1
0
        private static void ReadOracle(Object item, DbDataReader dr, int id, PropertyModel info)
        {
            object value    = null;
            var    typeName = dr.GetDataTypeName(id);

            if (string.Compare(typeName, "clob", true) == 0 || string.Compare(typeName, "nclob", true) == 0)
            {
                var temp = BaseEmit.Invoke(dr, dr.GetType().GetMethod("GetOracleClob"), new object[] { id });
                if (temp != null)
                {
                    value = BaseEmit.Get(temp, "Value");
                    BaseEmit.Invoke(temp, temp.GetType().GetMethod("Close"), null);
                    BaseEmit.Invoke(temp, temp.GetType().GetMethod("Dispose"), null);
                }
            }
            else if (string.Compare(typeName, "blob", true) == 0)
            {
                var temp = BaseEmit.Invoke(dr, dr.GetType().GetMethod("GetOracleBlob"), new object[] { id });
                if (temp != null)
                {
                    value = BaseEmit.Get(temp, "Value");
                    BaseEmit.Invoke(temp, temp.GetType().GetMethod("Close"), null);
                    BaseEmit.Invoke(temp, temp.GetType().GetMethod("Dispose"), null);
                }
            }
            else
            {
                value = dr.GetValue(id);
            }

            if (!dr.IsDBNull(id))
            {
                BaseEmit.Set(item, info.Name, value);
            }
        }
コード例 #2
0
        /// <summary>
        /// 泛型特性成员
        /// </summary>
        public static List <ColumnModel> GetAttributesColumnInfo(string tableName, List <PropertyInfo> ListInfo)
        {
            var list = new List <ColumnModel>();

            ListInfo.ForEach(a => {
                var temp      = new ColumnModel();
                temp.Name     = a.Name;
                var paramList = GetPropertyInfo <ColumnModel>(true);

                a.CustomAttributes.ToList().ForEach(b => {
                    if (b.AttributeType.Name == typeof(ColumnAttribute).Name)
                    {
                        b.NamedArguments.ToList().ForEach(c => {
                            if (paramList.Exists(p => string.Compare(p.Name, c.MemberName, true) == 0))
                            {
                                BaseEmit.Set(temp, c.MemberName, c.TypedValue.Value);
                            }
                        });
                    }
                });

                if (temp.IsKey && temp.IsNull)
                {
                    temp.IsNull = false;
                }

                list.Add(temp);
            });

            return(list);
        }
コード例 #3
0
        /// <summary>
        /// set value
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item"></param>
        /// <param name="dynSet"></param>
        /// <param name="dr"></param>
        /// <param name="info"></param>
        /// <param name="config"></param>
        private static T SetValue <T>(T item, DbDataReader dr, PropertyModel info, ConfigModel config)
        {
            try
            {
                var colName = config.DbType == DataDbType.Oracle ? info.Name.ToUpper() : info.Name;
                var id      = dr.GetOrdinal(colName);
                if (DataDbType.Oracle == config.DbType)
                {
                    ReadOracle(item, dr, id, info);
                }
                else if (!dr.IsDBNull(id))
                {
                    BaseEmit.Set(item, info.Name, dr.GetValue(id));
                }

                return(item);
            }
            catch { return(item); }
        }