本文整理汇总了C#中UpdateCommand类的典型用法代码示例。如果您正苦于以下问题:C# UpdateCommand类的具体用法?C# UpdateCommand怎么用?C# UpdateCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UpdateCommand类属于命名空间,在下文中一共展示了UpdateCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateEntity_ShouldUpdateEntity
public void UpdateEntity_ShouldUpdateEntity()
{
// arrange
var obj = new Author { Uid = AuthorUid};
var storageObj = new Author { Uid = AuthorUid };
var stub = new FakeRepository(new Dictionary<Type, IEnumerable<IEntity>>
{
{typeof (Author), new[] {new Author {Uid = Guid.NewGuid()}, storageObj}}
});
var updateCommand = new UpdateCommand<Author>();
// act
obj.Name = "foo bar";
obj.About = "sooo some foor";
obj.Company = "rook";
obj.SemanticUid = "foo_bar_rook";
updateCommand.Entity = obj;
updateCommand.Execute(stub);
// assert
Assert.AreEqual(obj.Name, storageObj.Name);
Assert.AreEqual(obj.About, storageObj.About);
Assert.AreEqual(obj.Company, storageObj.Company);
Assert.AreEqual(obj.SemanticUid, storageObj.SemanticUid);
}
示例2: Disable
public async Task<CodeFeatureModel> Disable(string codeFeatureId)
{
var updateCommand = new UpdateCommand(codeFeatureId, false);
await _updateCommandHandler.Execute(updateCommand);
return new CodeFeatureModel
{
CodeFeatureId = updateCommand.CodeFeatureId,
Enabled = updateCommand.Enabled,
};
}
示例3: GetNext
public static decimal GetNext(Transaction pTransaction, string pIDFieldValue)
{
decimal lID;
// Inicializa operação
OperationResult lReturn = new OperationResult(QueryDictionaries.SequencesQD.TableName, QueryDictionaries.SequencesQD.TableName);
// Recupera Valor
SelectCommand lSelectNext;
string lSelectQuery = QueryDictionaries.SequencesQD.qSequencesMax;
lSelectQuery += String.Format("WHERE {0} = >>{0}", QueryDictionaries.SequencesQD._SEQ_NAME.Name);
object lScalarReturn;
lSelectNext = new SelectCommand(lSelectQuery);
// Passagem dos Valores de Parametros para a Clausula WHERE [comando SELECT]
lSelectNext.Fields.Add(QueryDictionaries.SequencesQD._SEQ_NAME.Name, pIDFieldValue, ItemType.String);
// Recupera Valor do Select (Seq_Value)
lScalarReturn = lSelectNext.ReturnScalar(pTransaction);
if (lScalarReturn == null || lScalarReturn == DBNull.Value) lScalarReturn = 1;
lID = Convert.ToDecimal(lScalarReturn);
// Altera Valor da Sequence
UpdateCommand lUpdate;
lUpdate = new UpdateCommand(QueryDictionaries.SequencesQD.TableName);
// Identificação dos Campos a serem Alterados
lUpdate.Fields.Add(QueryDictionaries.SequencesQD._SEQ_VALUE.Name, lID, (ItemType) QueryDictionaries.SequencesQD._SEQ_VALUE.DBType);
string lUpdateQuery;
lUpdateQuery = String.Format("WHERE {0} = >>{0}", QueryDictionaries.SequencesQD._SEQ_NAME.Name);
lUpdate.Condition = lUpdateQuery;
// Passagem dos Valores para a Condição Where do Update
lUpdate.Conditions.Add(QueryDictionaries.SequencesQD._SEQ_NAME.Name, pIDFieldValue);
// Execução do UPDATE
lUpdate.Execute(pTransaction);
// Retorna novo valor da chave [SEQUENCE VALUE]
return lID;
}
示例4: Update
public static OperationResult Update(
DataFieldCollection pValues,
List<DataFieldCollection> pListAtuaInc,
List<DataFieldCollection> pListAtuaUpd,
DataFieldCollection pValuesAtuaExcluir,
List<DataFieldCollection> pListPermissao,
ConnectionInfo pInfo
)
{
Transaction pTransaction;
pTransaction = new Transaction(Instance.CreateDatabase(pInfo));
bool lLocalTransaction = (pTransaction != null);
UpdateCommand lUpdate;
OperationResult lReturn = new OperationResult(PessoaFuncaoQD.TableName, PessoaFuncaoQD.TableName);
ValidateUpdate(pValues, lReturn);
if (lReturn.IsValid)
{
try
{
lUpdate = new UpdateCommand(PessoaFuncaoQD.TableName);
foreach (DataField lField in pValues.Keys)
{
if ((lField.Name != PessoaFuncaoQD._PESF_ID.Name))
lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
}
string lSql = "";
lSql = String.Format("WHERE {0} = <<{0}", PessoaFuncaoQD._PESF_ID.Name);
lUpdate.Condition = lSql;
lUpdate.Conditions.Add(PessoaFuncaoQD._PESF_ID.Name, pValues[PessoaFuncaoQD._PESF_ID].DBToDecimal());
lUpdate.Execute(pTransaction);
if (!lReturn.HasError)
{
//Excluir atuação do núcleo alterado
if (pValuesAtuaExcluir.Count > 0)
{
lReturn = AtuacaoDo.UpdateInativo(pValuesAtuaExcluir, pInfo);
if (lReturn.HasError)
{
pTransaction.Rollback();
return lReturn;
}
}
if (pListAtuaInc.Count > 0)
{
foreach (DataFieldCollection lFields in pListAtuaInc)
{
lReturn = AtuacaoDo.Insert(lFields, pTransaction, pInfo);
if (lReturn.HasError)
{
pTransaction.Rollback();
return lReturn;
}
}
}
if (pListAtuaUpd.Count > 0)
{
foreach (DataFieldCollection lFields in pListAtuaUpd)
{
lReturn = AtuacaoDo.Update(lFields, pTransaction, pInfo);
if (lReturn.HasError)
{
pTransaction.Rollback();
return lReturn;
}
}
}
if (pListPermissao.Count > 0)
{
foreach (DataFieldCollection lFields in pListPermissao)
{
lReturn = SecurityUsersDtDo.Insert(lFields, pTransaction, pInfo);
if (lReturn.HasError)
{
pTransaction.Rollback();
return lReturn;
}
}
}
if (!lReturn.HasError)
{
pTransaction.Commit();
}
//.........这里部分代码省略.........
示例5: ZipUpdate
public ZipUpdate(UpdateCommand command, ZipEntry entry)
{
command_ = command;
entry_ = ( ZipEntry )entry.Clone();
}
示例6: BlubbUpdate
public BlubbUpdate( UpdateCommand command, BlubbZipEntry entry ) {
command_ = command;
entry_ = (BlubbZipEntry)entry.Clone();
}
示例7: ZipUpdate
public ZipUpdate(UpdateCommand command, ZipEntry entry)
{
command_ = command;
entry_ = ( ZipEntry )entry.Clone();
#if FORCE_ZIP64
entry_.ForceZip64();
#endif
}
示例8: GetUpdateExpression
public override Expression GetUpdateExpression(MappingEntity entity, Expression instance, LambdaExpression updateCheck, LambdaExpression selector, Expression @else)
{
var tableAlias = new TableAlias();
var table = new TableExpression(tableAlias, entity, this.mapping.GetTableName(entity));
var where = this.GetIdentityCheck(table, entity, instance);
if (updateCheck != null)
{
Expression typeProjector = this.GetEntityExpression(table, entity);
Expression pred = DbExpressionReplacer.Replace(updateCheck.Body, updateCheck.Parameters[0], typeProjector);
where = where.And(pred);
}
var assignments = this.GetColumnAssignments(table, instance, entity, (e, m) => this.mapping.IsUpdatable(e, m));
Expression update = new UpdateCommand(table, where, assignments);
if (selector != null)
{
return new BlockCommand(
update,
new IFCommand(
this.translator.Linguist.Language.GetRowsAffectedExpression(update).GreaterThan(Expression.Constant(0)),
this.GetUpdateResult(entity, instance, selector),
@else
)
);
}
else if (@else != null)
{
return new BlockCommand(
update,
new IFCommand(
this.translator.Linguist.Language.GetRowsAffectedExpression(update).LessThanOrEqual(Expression.Constant(0)),
@else,
null
)
);
}
else
{
return update;
}
}
示例9: VisitUpdate
protected override Expression VisitUpdate(UpdateCommand update)
{
this.Append("UPDATE ");
WriteTableName(update.Table.Mapping);
//if (Dialect.SupportSchema && !string.IsNullOrEmpty(update.Table.Mapping.Schema))
//{
// sb.Append(Dialect.Quote(update.Table.Mapping.Schema));
// sb.Append(".");
//}
//this.AppendTableName(update.Table.Name);
this.AppendLine(Indentation.Same);
bool saveHide = this.HideColumnAliases;
this.HideColumnAliases = true;
this.Append("SET ");
for (int i = 0, n = update.Assignments.Count; i < n; i++)
{
ColumnAssignment ca = update.Assignments[i];
if (i > 0) this.Append(", ");
this.Visit(ca.Column);
this.Append(" = ");
this.Visit(ca.Expression);
}
if (update.Where != null)
{
this.AppendLine(Indentation.Same);
this.Append("WHERE ");
this.VisitPredicate(update.Where);
}
this.HideColumnAliases = saveHide;
return update;
}
示例10: ChangePassword
public static string ChangePassword(decimal pSusr_Id, string pSusr_Login, string pSusr_Password_old, string pSusr_Password_new, ConnectionInfo pConnectionInfo)
{
bool lPasswordOK;
string lPassword;
string lResult = "";
OperationResult lReturn;
Transaction pTransaction;
pTransaction = new Transaction(Instance.CreateDatabase(pConnectionInfo));
// Validando a Senha Digitada.
lPassword = GetPassword(pSusr_Login, pConnectionInfo);
lPasswordOK = (lPassword == pSusr_Password_old) ? true : false;
if (!lPasswordOK)
lResult = "Senha Atual Incorreta";
// Verificando Transação
bool lLocalTransaction = (pTransaction != null);
UpdateCommand lUpdate;
lReturn = new OperationResult(SystemUserQD.TableName, SystemUserQD.TableName);
if (lPasswordOK)
{
// Iniciando processo de update...
if (lReturn.IsValid)
{
try
{
if (lLocalTransaction)
{
lReturn.Trace("ExternalUser: Transação local, instanciando banco...");
}
lUpdate = new UpdateCommand(SystemUserQD.TableName);
lReturn.Trace("ExternalUser: Adicionando campos ao objeto de update");
lUpdate.Fields.Add(SystemUserQD._SUSR_PASSWORD.Name, APB.Framework.Encryption.Crypto.Encode(pSusr_Password_new), (ItemType)SystemUserQD._SUSR_PASSWORD.DBType);
string lSql = "";
//TODO: Condição where customizada
lSql = String.Format("WHERE {0} = >>{0}", SystemUserQD._SUSR_ID.Name);
lUpdate.Condition = lSql;
lUpdate.Conditions.Add(SystemUserQD._SUSR_ID.Name, pSusr_Id);
lReturn.Trace("ExternalUser: Executando o Update");
lUpdate.Execute(pTransaction);
if (!lReturn.HasError)
{
if (lLocalTransaction)
{
if (!lReturn.HasError)
{
lReturn.Trace("ExternalUser: Update finalizado, executando commit");
pTransaction.Commit();
}
else
{
pTransaction.Rollback();
}
}
}
else
{
if (lLocalTransaction)
pTransaction.Rollback();
}
}
catch (Exception ex)
{
lReturn.OperationException = new SerializableException(ex);
if (lLocalTransaction)
pTransaction.Rollback();
}
}
}
else
{
return "Senha atual incorreta";
}
if (lReturn.IsValid)
lResult = "";
else
lResult = lReturn.ToString();
return lResult;
}
示例11: UpdateInativo
public static OperationResult UpdateInativo(
DataFieldCollection pValues,
ConnectionInfo pInfo
)
{
Transaction pTransaction;
pTransaction = new Transaction(Instance.CreateDatabase(pInfo));
bool lLocalTransaction = (pTransaction != null);
UpdateCommand lUpdate;
OperationResult lReturn = new OperationResult(AtuacaoQD.TableName, AtuacaoQD.TableName);
if (lReturn.IsValid)
{
try
{
lUpdate = new UpdateCommand(AtuacaoQD.TableName);
foreach (DataField lField in pValues.Keys)
{
if ((lField.Name != AtuacaoQD._PESF_ID.Name))
lUpdate.Fields.Add(lField.Name, pValues[lField], (ItemType)lField.DBType);
}
string lSql = "";
lSql = String.Format("WHERE {0} = <<{0}", AtuacaoQD._PESF_ID.Name);
lUpdate.Condition = lSql;
lUpdate.Conditions.Add(AtuacaoQD._PESF_ID.Name, pValues[AtuacaoQD._PESF_ID].DBToDecimal());
lUpdate.Execute(pTransaction);
if (!lReturn.HasError)
{
if (lLocalTransaction)
{
if (!lReturn.HasError)
{
pTransaction.Commit();
}
else
{
pTransaction.Rollback();
}
}
}
else
{
if (lLocalTransaction)
pTransaction.Rollback();
}
}
catch (Exception ex)
{
lReturn.OperationException = new SerializableException(ex);
if (lLocalTransaction)
pTransaction.Rollback();
}
}
return lReturn;
}
示例12: VisitUpdate
protected virtual Expression VisitUpdate(UpdateCommand update)
{
var table = (TableExpression)this.Visit(update.Table);
var where = this.Visit(update.Where);
var assignments = this.VisitColumnAssignments(update.Assignments);
return this.UpdateUpdate(update, table, where, assignments);
}
示例13: UpdateUpdate
protected UpdateCommand UpdateUpdate(UpdateCommand update, TableExpression table, Expression where, IEnumerable<ColumnAssignment> assignments)
{
if (table != update.Table || where != update.Where || assignments != update.Assignments)
{
return new UpdateCommand(table, where, assignments);
}
return update;
}
示例14: GetUpdateExpression
public virtual Expression GetUpdateExpression(IEntityMapping mapping, Expression instance, LambdaExpression updateCheck, LambdaExpression selector, Expression @else)
{
var tableAlias = new TableAlias();
var table = new TableExpression(tableAlias, mapping);
var where = this.GetIdentityCheck(table, mapping, instance);
if (updateCheck != null)
{
Expression typeProjector = this.GetEntityExpression(table, mapping);
Expression pred = DbExpressionReplacer.Replace(updateCheck.Body, updateCheck.Parameters[0], typeProjector);
where = where != null ? where.And(pred) : pred;
}
var assignments = this.GetColumnAssignments(table, instance, mapping, m => m.IsUpdatable && !m.IsVersion);
var version = mapping.Version;
bool supportsVersionCheck = false;
if (version != null)
{
var versionValue = GetVersionValue(mapping, instance);
var versionExp = Expression.Constant(versionValue, version.MemberType);
var memberExpression = GetMemberExpression(table, mapping, mapping.Version);
var versionCheck = memberExpression.Equal(versionExp);
where = (where != null) ? where.And(versionCheck) : versionCheck;
if (version.MemberType.IsNullable())
{
var versionAssignment = new ColumnAssignment(
memberExpression as ColumnExpression,
versionValue == null ?
(Expression)Expression.Constant(1, version.MemberType)
: Expression.Add(memberExpression, Expression.Constant(1, version.MemberType))
);
assignments.Add(versionAssignment);
supportsVersionCheck = true;
}
else
{
var versionAssignment = new ColumnAssignment(
memberExpression as ColumnExpression,
Expression.Add(memberExpression, Expression.Constant(1, version.MemberType))
);
assignments.Add(versionAssignment);
supportsVersionCheck = true;
}
}
object o = null;
var c = instance as ConstantExpression;
if (c != null)
o = c.Value;
Expression update = new UpdateCommand(table, where, o, supportsVersionCheck, assignments);
if (selector != null)
{
return new BlockCommand(
update,
new IFCommand(
this.GetRowsAffectedExpression(update).GreaterThan(Expression.Constant(0)),
this.GetUpdateResult(mapping, instance, selector),
@else
)
);
}
else if (@else != null)
{
return new BlockCommand(
update,
new IFCommand(
this.GetRowsAffectedExpression(update).LessThanOrEqual(Expression.Constant(0)),
@else,
null
)
);
}
else
{
return update;
}
}
示例15: DetermineStateEntriesFromSource
private IEnumerable<IEntityStateEntry> DetermineStateEntriesFromSource(UpdateCommand source)
{
if (null == source)
{
return Enumerable.Empty<IEntityStateEntry>();
}
return source.GetStateEntries(this);
}