Пример #1
0
 private string GenColumnCreateTableSql(ColumnFieldDefinition cfd)
 {
     GenCreateSqlFuncDic();
     if (!createSqlFuncDic.ContainsKey(cfd.FieldType))
     {
         throw new NLORM.Core.Exceptions.NLORMException("SG", "NOT SUPPORT DBTYPE");
     }
     return(createSqlFuncDic[cfd.FieldType](cfd));
 }
Пример #2
0
 private void AsignColTypeAttrToDef(ColumnFieldDefinition colunmF,
                                    ColumnTypeAttribute colTypeAttr, PropertyInfo prop)
 {
     if (colTypeAttr != null)
     {
         colunmF.PropName  = prop.Name;
         colunmF.FieldType = colTypeAttr.DBType;
         colunmF.Length    = colTypeAttr.Length;
         colunmF.Nullable  = colTypeAttr.Nullable;
         colunmF.Comment   = colTypeAttr.Comment;
     }
     else
     {
         colunmF.PropName  = prop.Name;
         colunmF.FieldType = Dapper.SqlMapper.LookupDbType(prop.PropertyType, prop.Name);
     }
 }
Пример #3
0
        private string GenCreateSqlByType(ColumnFieldDefinition cfd, string type, string length = "")
        {
            var ret = "";

            ret += " " + cfd.ColumnName + " ";
            var nullable = cfd.Nullable ? "" : "not null";

            if (string.IsNullOrEmpty(length))
            {
                ret += type + " " + nullable;
            }
            else
            {
                ret += type + "(" + length + ") " + nullable;
            }
            return(ret);
        }
Пример #4
0
        private ColumnFieldDefinition GetColumnFieldDefByProprty(PropertyInfo prop)
        {
            object[]            attrs       = prop.GetCustomAttributes(true);
            var                 ret         = new ColumnFieldDefinition();
            ColumnNameAttribute colNameAttr = null;
            ColumnTypeAttribute colTypeAttr = null;

            foreach (object attr in attrs)
            {
                if (attr.GetType().Equals(typeof(ColumnNameAttribute)))
                {
                    colNameAttr = attr as ColumnNameAttribute;
                }
                if (attr.GetType().Equals(typeof(ColumnTypeAttribute)))
                {
                    colTypeAttr = attr as ColumnTypeAttribute;
                }
            }
            AsignColNameAttrToDef(ret, colNameAttr, prop);
            AsignColTypeAttrToDef(ret, colTypeAttr, prop);
            return(ret);
        }
Пример #5
0
 private void AsignColNameAttrToDef(ColumnFieldDefinition colunmF,
                                    ColumnNameAttribute colNameAttr, PropertyInfo prop)
 {
     colunmF.ColumnName = colNameAttr == null ? prop.Name : colNameAttr.ColumnName;
 }
Пример #6
0
 virtual public string GenCreateBigint(ColumnFieldDefinition cfd)
 {
     return(GenCreateSqlByType(cfd, "bigint", null));
 }
Пример #7
0
 virtual public string GenCreateTime(ColumnFieldDefinition cfd)
 {
     return(GenCreateSqlByType(cfd, "time", null));
 }
Пример #8
0
 virtual public string GenCreateReal(ColumnFieldDefinition cfd)
 {
     return(GenCreateSqlByType(cfd, "real", null));
 }
Пример #9
0
        virtual public string GenCreateDecimal(ColumnFieldDefinition cfd)
        {
            var length = string.IsNullOrEmpty(cfd.Length) ? StringDeafultLength : cfd.Length;

            return(GenCreateSqlByType(cfd, "decimal", length));
        }
Пример #10
0
 virtual public string GenCreateDateTime(ColumnFieldDefinition cfd)
 {
     return(GenCreateSqlByType(cfd, "DATETIME"));
 }
Пример #11
0
 virtual public string GenCreateInteger(ColumnFieldDefinition cfd)
 {
     return(GenCreateSqlByType(cfd, "INTEGER"));
 }