internal void copyToSinkObject(ISerializableObject from, ISerializableObject to)
        {
            AttributeWorker w = AttributeWorker.GetInstance(sinkSerializer.Target);//Am besten durch Kopiervorgang ersetzen, der ohne Attributeworker auskommt.

            FieldInfo[] fis = AttributeWorker.RetrieveAllFields(from.GetType());

            foreach (FieldInfo fi in fis)
            {
                if (w.IsAutoincID(fi))
                {
                    continue;                   //Kann man aus Lookup-Tabelle holen
                }
                if (!w.IsPersistentField(fi))
                {
                    continue;                          //wirklich  nötig?
                }
                //DirectSync wird im Moment nicht unterstützt
                if (AttributeWorker.IsRowGuid(fi))
                {
                    continue;                               //Kann man als Lookup-Tabelle definieren
                }
                Object val = fi.GetValue(from);
                fi.SetValue(to, val);
            }
        }
Exemplo n.º 2
0
        internal static void PlainCopy(Serializer context, ISerializableObject from, ISerializableObject to, FieldLock fieldLock, bool forceForeignKeyCopy)
        {
            AttributeWorker w = AttributeWorker.GetInstance(context.Target);

            FieldInfo[] fis = AttributeWorker.RetrieveAllFields(from.GetType());

            foreach (FieldInfo fi in fis)
            {
                if (fieldLock.IsLocked(fi))
                {
                    continue;
                }
                if (AttributeWorker.IsRelationField(fi))
                {
                    continue;
                }
                if (w.IsAutoincID(fi))
                {
                    continue;
                }
                if (!w.IsPersistentField(fi))
                {
                    continue;
                }
                if (AttributeWorker.IsRowGuid(fi))
                {
                    continue;
                }
                if (w.IsForeignKey(context, fi) && !forceForeignKeyCopy)
                {
                    DirectSyncAttribute a = (DirectSyncAttribute)Attribute.GetCustomAttribute(fi, typeof(DirectSyncAttribute));

                    if (a == null)
                    {
                        continue;
                    }
                }


                Object val = fi.GetValue(from);
                fi.SetValue(to, val);
            }
        }
Exemplo n.º 3
0
        internal virtual String SerializeUpdate(ISerializableObject iso, ref UpdateStates state, GenericWeakReference <ISerializableObject> tmp)
        {
            AttributeWorker w   = AttributeWorker.GetInstance(Target);
            StringBuilder   sql = new StringBuilder();

            StringBuilder where = new StringBuilder();

            Guid      g = AttributeWorker.RowGuid(iso);
            FieldInfo f = AttributeWorker.RowGuid(iso.GetType());

            sql.Append("UPDATE ").Append(w.GetTableMapping(iso.GetType(), _praefix));
            sql.Append(" SET ");
            where.Append(" WHERE ").Append(AttributeWorker.GetInstance(Target).GetColumnMapping(f));
            where.Append("='").Append(g).Append("'");;

            FieldInfo[] fis = AttributeWorker.RetrieveAllFields(iso.GetType());



            bool start = true;

            foreach (FieldInfo fi in fis)
            {
                try
                {
                    String col = w.GetColumnMapping(fi);
                    Object val = fi.GetValue(iso);
                    Object oldVal;


                    if (w.IsAutoincID(fi))
                    {
                        continue;
                    }
                    if (AttributeWorker.IsRowGuid(fi))
                    {
                        continue;
                    }

                    if (w.IsID(fi))
                    {
                        oldVal = tmp.Properties[fi.Name];
                        if (!Object.Equals(val, oldVal))
                        {
                            state = UpdateStates.PRIMARYKEY_MODIFIED;
                        }
                        tmp.Properties[fi.Name] = val;
                    }

                    if (!start)
                    {
                        sql.Append(", ");
                    }
                    else
                    {
                        start = false;
                    }

                    sql.Append(col).Append("=").Append(SqlUtil.SqlConvert(val));
                }
                catch (SerializerException) { }
            }

            sql.Append(where);
            return(sql.ToString());
        }