Esempio n. 1
0
        public HelperSQL()
        {
            PropertyInfo pkProp = typeof(T).GetProperties().Where(p => p.GetCustomAttributes(typeof(KeyAttribute), false).Length > 0).FirstOrDefault();

            if (pkProp != null)
            {
                _primaryKeyField = pkProp.Name;
            }

            foreach (PropertyInfo prop in typeof(T).GetProperties())
            {
                if (prop.GetCustomAttributes <NotMappedAttribute>().Count() > 0)
                {
                    continue;
                }
                MaxLengthAttribute    maxLength    = prop.GetCustomAttribute <MaxLengthAttribute>();
                MinLengthAttribute    minLength    = prop.GetCustomAttribute <MinLengthAttribute>();
                StringLengthAttribute stringLength = prop.GetCustomAttribute <StringLengthAttribute>();
                RequiredAttribute     required     = prop.GetCustomAttribute <RequiredAttribute>();
                RangeAttribute        range        = prop.GetCustomAttribute <RangeAttribute>();
                DataTypeAttribute     dataType     = prop.GetCustomAttribute <DataTypeAttribute>();
                KeyAttribute          key          = prop.GetCustomAttribute <KeyAttribute>();

                var cl = new BuildClass
                {
                    Name      = prop.Name,
                    MaxLength = maxLength != null
                    ? (int?)maxLength.Length
                    : stringLength != null
                        ? (int?)stringLength.MaximumLength : null,
                    MinLength = minLength != null
                    ? (int?)minLength.Length
                    : stringLength != null
                        ? (int?)stringLength.MinimumLength : null,
                    PrimaryKey = key != null ? true : false,
                    Type       = prop.PropertyType.Name.ToString()
                };
                _class.Add(cl);
            }
        }
Esempio n. 2
0
        public static DataTable ExecuteQuery(String sql)
        {
            FactoryInterface fi = BuildClass.build("ExecuteQuery");//BuildClass.build("ExecuteQuery");

            return((DataTable)fi.create().create(sql));
        }
Esempio n. 3
0
        public static int ExecuteUpdata(String sql)
        {
            FactoryInterface fi = BuildClass.build("ExecuteUpdata");//BuildClass.build("ExecuteQuery");

            return((int)fi.create().create(sql));
        }