Beispiel #1
0
        private EntityObject GetCurrentNumber(string fixString)
        {
            EntityObject resValue = null;

            string sql = string.Format("Select value c from {0}.{1} as c", Context.DefaultContainerName, AutoNumberTableName);
            ObjectQuery<EntityObject> query = this.Context.CreateQuery<EntityObject>(sql);
            var parameterPrefix = EntityProvider.GetParameterPrefix(query.Context);
            List<WhereParameter> listWhereParameter = new List<WhereParameter>();
            WhereParameter whereParameter = new WhereParameter();
            whereParameter.Field = SYSAUTONUMBER.AUTOID;
            whereParameter.Value = this.AutoNoID;
            listWhereParameter.Add(whereParameter);

            if (!this.IsNumFill)
            {
                whereParameter = new WhereParameter();
                whereParameter.Field = SYSAUTONUMBER.FIXED;
                whereParameter.And = true;
                whereParameter.Value = fixString;
                listWhereParameter.Add(whereParameter);
            }

            query = EntityProvider.SetWhere(query, listWhereParameter);
            List<EntityObject> objects = query.ToList();
            if (objects.Count != 0)
            {
                resValue = objects[0];
            }
            return resValue;
        }
Beispiel #2
0
        private EntityObject GetDestinationObject(Transaction transaction, List<TransKeyField> transKeyFields, EntityState state, bool isGetOldKeyObject)
        {
            EntityObject resValue = null;

            string sql = string.Format("Select value c from {0}.{1} as c", Context.DefaultContainerName, transaction.TransTableName);
            ObjectQuery<EntityObject> query = this.Context.CreateQuery<EntityObject>(sql);
            var parameterPrefix = EntityProvider.GetParameterPrefix(query.Context);
            List<WhereParameter> listWhereParameter = new List<WhereParameter>();

            foreach (var keyField in transKeyFields)
            {
                if (keyField.WhereMode != WhereMode.InsertOnly)
                {
                    WhereParameter whereParameter = new WhereParameter();
                    whereParameter.And = true;
                    whereParameter.Field = keyField.DesField;
                    switch (state)
                    {
                        case EntityState.Added:
                            whereParameter.Value = keyField.NewValue;
                            break;
                        case EntityState.Deleted:
                            whereParameter.Value = keyField.OldValue;
                            break;
                        case EntityState.Modified:
                            whereParameter.Value = isGetOldKeyObject == true ? keyField.OldValue : keyField.NewValue;
                            break;
                    }
                    listWhereParameter.Add(whereParameter);
                }
            }

            query = EntityProvider.SetWhere(query, listWhereParameter);
            List<EntityObject> objects = query.ToList();
            if (objects.Count != 0)
            {
                resValue = objects[0];
            }
            return resValue;
        }