private void ActualizeMetaData(UserConnection userConnection, MetaDataInfo metaDataInfo, bool isParentActualize = false)
        {
            var entityId         = isParentActualize ? metaDataInfo.ParentId : metaDataInfo.EntityId;
            var entitySchemaName = isParentActualize ? metaDataInfo.ParentSchemaName : metaDataInfo.EntitySchemaName;
            var syncAction       = isParentActualize ? SyncAction.Update : metaDataInfo.SyncAction;

            if (syncAction == SyncAction.Create && !IsDetailSchemaName(entitySchemaName))
            {
                return;
            }
            var actualizeMetaData = new Update(userConnection, "SysSyncMetaData")
                                    .Set("Version", Column.Parameter(metaDataInfo.ModifiedOn))
                                    .Set("ModifiedOn", Column.Parameter(metaDataInfo.ModifiedOn))
                                    .Set("ModifiedInStoreId", Column.Parameter(ExchangeConsts.LocalStoreId))
                                    .Set("LocalState", Column.Parameter(syncAction))
                                    .Where("LocalId").IsEqual(Column.Parameter(entityId))
                                    .And("RemoteStoreId").IsEqual(Column.Parameter(StoreId))
                                    .And("SyncSchemaName").IsEqual(Column.Parameter(entitySchemaName));

            if (syncAction != SyncAction.Delete)
            {
                actualizeMetaData = actualizeMetaData
                                    .And("CreatedById").IsEqual(Column.Parameter(metaDataInfo.UserContactId)) as Update;
            }
            actualizeMetaData.Execute();
        }
 private void ActualizeDetailMetaData(UserConnection userConnection, MetaDataInfo metaDataInfo)
 {
     metaDataInfo.SetParentProperties(userConnection);
     if (metaDataInfo.ParentRemoteId.IsNullOrEmpty())
     {
         return;
     }
     if (metaDataInfo.SyncAction == SyncAction.Create)
     {
         InsertMetaData(userConnection, metaDataInfo);
     }
     else
     {
         ActualizeMetaData(userConnection, metaDataInfo);
     }
     ActualizeMetaData(userConnection, metaDataInfo, true);
 }
        private void InsertMetaData(UserConnection userConnection, MetaDataInfo metaDataInfo)
        {
            var insert = new Insert(userConnection).Into("SysSyncMetaData")
                         .Set("LocalId", Column.Parameter(metaDataInfo.EntityId))
                         .Set("Version", Column.Parameter(metaDataInfo.ModifiedOn))
                         .Set("RemoteId", Column.Parameter(metaDataInfo.ParentRemoteId))
                         .Set("LocalState", Column.Parameter(SyncAction.Create))
                         .Set("RemoteStoreId", Column.Parameter(StoreId))
                         .Set("CreatedOn", Column.Parameter(metaDataInfo.ModifiedOn))
                         .Set("ModifiedOn", Column.Parameter(metaDataInfo.ModifiedOn))
                         .Set("CreatedById", Column.Parameter(metaDataInfo.UserContactId))
                         .Set("ModifiedById", Column.Parameter(metaDataInfo.UserContactId))
                         .Set("SyncSchemaName", Column.Parameter(metaDataInfo.EntitySchemaName))
                         .Set("ModifiedInStoreId", Column.Parameter(ExchangeConsts.LocalStoreId))
                         .Set("CreatedInStoreId", Column.Parameter(ExchangeConsts.LocalStoreId))
                         .Set("SchemaOrder", Column.Parameter(SchemaOrder))
                         .Set("RemoteItemName", Column.Parameter(RemoteItemName));

            insert.Execute();
        }