示例#1
0
 public void Add(PersistentObject dpo)
 {
     dpo.SetTransaction(this);
 }
示例#2
0
 public RowObjectAdapter(PersistentObject obj)
     : this(obj, new Selector())
 {
     this.obj = obj;
 }
示例#3
0
文件: Mapping.cs 项目: fjiang2/sqlcon
        private SqlBuilder clause2;     //B := SELECT * FROM Roles WHERE Roles.Role_ID IN (A)

        public Mapping(PersistentObject dpo, PropertyInfo propertyInfo2)
        {
            this.association = Reflex.GetAssociationAttribute(propertyInfo2);

            if (association == null)
            {
                return;
            }

            this.dpoInstance   = dpo;
            this.propertyInfo2 = propertyInfo2;

            Type dpoType2;            //typeof(RoleDpo)

            if (propertyInfo2.PropertyType.IsGenericType)
            {
                dpoType2 = PersistentObject.GetCollectionGenericType(propertyInfo2);

                if (this.association.TRelation == null)
                {
                    mappingType = MappingType.One2Many;
                }
                else
                {
                    mappingType = MappingType.Many2Many;
                }
            }
            else
            {
                dpoType2    = propertyInfo2.PropertyType;
                mappingType = MappingType.One2One;
            }



            this.propertyInfo1 = dpo.GetType().GetProperty(association.Column1);


            if (mappingType == MappingType.Many2Many)
            {
                this.clause1 = new SqlBuilder()
                               .SELECT().COLUMNS(association.Relation2)
                               .FROM(association.TRelation)
                               .WHERE(association.Relation1.ColumnName() == association.Column1.ParameterName());

                this.clause2 = new SqlBuilder()
                               .SELECT()
                               .COLUMNS()
                               .FROM(dpoType2)
                               .WHERE(association.Relation2.ColumnName().IN(this.clause1));
            }
            else
            {
                SqlExpr where = association.Column2.ColumnName() == association.Column1.ParameterName();
                if (association.Filter != null)
                {
                    where = where.AND(association.Filter);
                }

                this.clause2 = new SqlBuilder()
                               .SELECT()
                               .COLUMNS()
                               .FROM(dpoType2)
                               .WHERE(where);

                if (association.OrderBy != null)
                {
                    this.clause2 = clause2.ORDER_BY(association.OrderBy);
                }
            }
        }