Ejemplo n.º 1
0
        public override void JoinsDelete(ClassType Object, MicroORM MicroORM)
        {
            if (Object == null)
            {
                return;
            }
            IEnumerable <DataType> List = CompiledExpression(Object);

            if (List == null)
            {
                return;
            }
            foreach (DataType Item in List)
            {
                if (Item != null)
                {
                    IParameter CurrentIDParameter = ((IProperty <ClassType>)Mapping.IDProperty).GetAsParameter(Object);
                    CurrentIDParameter.ID = "ID";
                    MicroORM.Command      = "DELETE FROM " + TableName + " WHERE " + Mapping.TableName + Mapping.IDProperty.FieldName + "=@ID";
                    MicroORM.CommandType  = CommandType.Text;
                    CurrentIDParameter.AddParameter(MicroORM);
                    MicroORM.ExecuteNonQuery();
                }
            }
        }
Ejemplo n.º 2
0
        public override void JoinsSave(ClassType Object, MicroORM MicroORM)
        {
            if (Object == null)
            {
                return;
            }
            IEnumerable <DataType> List = CompiledExpression(Object);

            if (List == null)
            {
                return;
            }
            foreach (DataType Item in List)
            {
                if (Item != null)
                {
                    IParameter CurrentIDParameter = ((IProperty <ClassType>)Mapping.IDProperty).GetAsParameter(Object);
                    IMapping   ForeignMapping     = Mapping.Manager.Mappings[typeof(DataType)].First(x => x.DatabaseConfigType == Mapping.DatabaseConfigType);
                    IParameter ForeignIDParameter = ((IProperty <DataType>)ForeignMapping.IDProperty).GetAsParameter(Item);
                    CurrentIDParameter.ID = "ID1";
                    ForeignIDParameter.ID = "ID2";
                    MicroORM.Command      = "INSERT INTO " + TableName + "(" + Mapping.TableName + Mapping.IDProperty.FieldName + "," + ForeignMapping.TableName + ForeignMapping.IDProperty.FieldName + ") VALUES (@ID1,@ID2)";
                    MicroORM.CommandType  = CommandType.Text;
                    CurrentIDParameter.AddParameter(MicroORM);
                    ForeignIDParameter.AddParameter(MicroORM);
                    MicroORM.ExecuteNonQuery();
                }
            }
        }