Exemple #1
0
        public string GetFieldTypeName(string FieldName)
        {
            ColumnMap cm = default(ColumnMap);

            if (this.columns.TryGetValue(FieldName, out cm))
            {
                return(cm.MemberExpression.Type.FullName);
            }
            return(string.Empty);
        }
Exemple #2
0
        public ORMBuilder <T> MapColumn(Expression <Func <T, object> > expression, string ColumnName, string DbType = "")
        {
            ColumnMap ColumnMap = expression.GetColumnMap(ColumnName);

            ColumnMap.DbType = DbType;
            if (ColumnMap != null)
            {
                this.Columns[ColumnMap.FieldName] = ColumnMap;
            }
            return(this);
        }
Exemple #3
0
        public string BuildQueryMap(string InstanceName, ColumnMap map)
        {
            string method = string.Empty;
            Type   type   = map.MemberExpression.Type;

            if (type == typeof(int))
            {
                method = "GetInt";
            }
            else if (type == typeof(int?))
            {
                method = "GetIntNullable";
            }
            else if (type == typeof(long))
            {
                method = "GetLong";
            }
            else if (type == typeof(long?))
            {
                method = "GetLongNullable";
            }
            else if (type == typeof(Decimal))
            {
                method = "GetDecimal";
            }
            else if (type == typeof(Decimal?))
            {
                method = "GetDecimalNullable";
            }
            else if (type == typeof(DateTime))
            {
                method = "GetDateTime";
            }
            else if (type == typeof(DateTime?))
            {
                method = "GetDateTimeNullable";
            }
            else if (type == typeof(bool))
            {
                method = "GetBoolean";
            }
            else if (type == typeof(bool?))
            {
                method = "GetBooleanNullable";
            }
            else if (type == typeof(Guid))
            {
                method = "GetGuid";
            }
            else if (type == typeof(Guid?))
            {
                method = "GetGuidNullable";
            }
            else if (type == typeof(string))
            {
                method = "GetStringNullable";
            }
            StringBuilder sb = new StringBuilder();
            string        s  = string.Empty;

            if (!string.IsNullOrEmpty(method))
            {
                s = string.Format("{3}.{0}=reader.{1}(\"{2}\");", map.FieldName, method, map.ColumnName, InstanceName);
            }
            else
            {
                s = string.Format("{3}.{0}=reader.GetValue<{1}>(\"{2}\");", map.FieldName, map.MemberExpression.Type.Name, map.ColumnName, InstanceName);
            }
            sb.Append("try{");
            sb.Append(s);
            sb.Append("}");

            sb.Append("catch{");
            sb.Append("}");
            return(sb.ToString());
        }
Exemple #4
0
 public string BuildUpdateMap(ColumnMap map)
 {
     return(string.Format("AppendDataMap(type, \"{0}\", () => entity.{1});", map.ColumnName, map.FieldName));
 }