Esempio n. 1
0
File: SQL.cs Progetto: yanyitec/Itec
        public SQL(string membersString, SQLBag <T> sqlBag)
        {
            this.SqlBag       = sqlBag;
            this.Database     = sqlBag.Database;
            this.DbSettings   = this.Database.Settings;
            this.DbTrait      = this.Database.Trait;
            this.DbClass      = sqlBag.DbClass;
            this.FieldedProps = this.DbClass.FieldedProps;

            this.MembersString = membersString ?? string.Empty;
            if (string.IsNullOrEmpty(this.MembersString) || this.MembersString == "*")
            {
                this._AllowedProps = this.DbClass.FieldedProps;
                this.MembersString = "*";
            }
            else
            {
                var memberNames = MembersString.Split(',');
                var props       = new Dictionary <string, IDbProperty>();
                _AllowedProps = props;
                foreach (var mName in memberNames)
                {
                    var         memName = mName.Trim();
                    IDbProperty prop    = null;
                    if (this.DbClass.FieldedProps.TryGetValue(memName, out prop))
                    {
                        props.Add(prop.Name, prop);
                    }
                }
                if (!props.ContainsKey(this.DbClass.PrimaryProperty.Name))
                {
                    props.Add(this.DbClass.PrimaryProperty.Name, this.DbClass.PrimaryProperty);
                }
            }



            this.Create     = new Create <T>(this);
            this.Insert     = new Insert <T>(this);
            this.Select     = new Select <T>(this);
            this.Count      = new Count <T>(this);
            this.Get        = new Get <T>(this);
            this.GetById    = new GetById <T>(this);
            this.Update     = new Update <T>(this);
            this.Save       = new Save <T>(this);
            this.Delete     = new Delete <T>(this);
            this.DeleteById = new DeleteById <T>(this);
            //this.Select = new Select(model, membersString);
        }
Esempio n. 2
0
File: SQL.cs Progetto: yanyitec/Itec
        public SQL(string membersString, Database db, IDbClass dbClass)
        {
            this.Database     = db;
            this.DbSettings   = db.Settings;
            this.DbTrait      = db.Trait;
            this.DbClass      = dbClass;
            this.FieldedProps = this.DbClass.FieldedProps;

            this.MembersString = membersString ?? string.Empty;
            if (string.IsNullOrEmpty(this.MembersString) || this.MembersString == "*")
            {
                this._AllowedProps = this.DbClass.FieldedProps;
                this.MembersString = "*";
            }
            else
            {
                var memberNames = MembersString.Split(',');
                var props       = new Dictionary <string, IDbProperty>();
                _AllowedProps = props;
                foreach (var mName in memberNames)
                {
                    var         memName = mName.Trim();
                    IDbProperty prop    = null;
                    if (this.DbClass.FieldedProps.TryGetValue(memName, out prop))
                    {
                        props.Add(prop.Field.Name, prop);
                    }
                }
            }



            this.Create = new Create <T>(this);
            this.Insert = new Insert <T>(this);
            //this.Update = new Update(model, membersString);
            //this.Select = new Select(model, membersString);
        }