コード例 #1
0
        public static string GetTableName(Type type)
        {
            DBClassAttribute attribute = GetDBClassAttributes(type);

            if (attribute == null)
            {
                throw new Exception("Invalid DBClassAttribute Setting");
            }
            return(attribute.tableName);
        }
コード例 #2
0
ファイル: DBManager.cs プロジェクト: dhamotharang/H-R-One
        public DBManager(Type type)
        {
            System.Diagnostics.Debug.Write("Initialize DBManager for " + type.Name + ".");
            this.type = type;
            m_dbclass = DBUtils.GetDBClassAttributes(type);
            if (m_dbclass == null)
            {
                m_dbclass = new DBClassAttribute(type.Name);
            }
            System.Diagnostics.Debug.Write(".");


            fieldDictionary = new Dictionary <string, DBField>();
            fieldList       = fieldDictionary.Values;
            keyFieldList    = new List <DBField>();

            PropertyInfo[] propInfoList = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

            foreach (PropertyInfo propInfo in propInfoList)
            {
                object[] attributeList = propInfo.GetCustomAttributes(typeof(DBFieldAttribute), false);

                foreach (Attribute attribute in attributeList)
                {
                    if (attribute is DBFieldAttribute)
                    {
                        DBFieldAttribute fieldAttribute = (DBFieldAttribute)attribute;
                        DBField          field          = new DBField(fieldAttribute, propInfo);

                        fieldDictionary.Add(fieldAttribute.columnName, field);

                        if (fieldAttribute.isKey)
                        {
                            keyFieldList.Add(field);
                        }

                        //if (!string.IsNullOrEmpty(fieldAttribute.columnName))
                        //{
                        //    object value = SourceRow[fieldAttribute.columnName];
                        //    if (field.transcoder != null)
                        //        value = field.transcoder.fromDB(value);
                        //    propInfo.SetValue(DestinationDBObject, value, null);
                        //}
                    }
                }
            }
            System.Diagnostics.Debug.Write(".");
            prepareSQLStatement();
            System.Diagnostics.Debug.WriteLine(".done");
        }