本文整理汇总了C#中IObjectContainer.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectContainer.Commit方法的具体用法?C# IObjectContainer.Commit怎么用?C# IObjectContainer.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectContainer
的用法示例。
在下文中一共展示了IObjectContainer.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exercise
protected override void Exercise(IObjectContainer db)
{
Assert.AreEqual(1, db.Query(typeof(ConcurrentRenameTestCase.QueryItem)).Count);
ConcurrentRenameTestCase.QueryItem newItem = new ConcurrentRenameTestCase.QueryItem
();
db.Store(newItem);
db.Commit();
db.Delete(newItem);
db.Commit();
}
示例2: cadastrarCliente
public Boolean cadastrarCliente(Cliente objCliente)
{
objCliente.Codigo = obtemNovoId();
try
{
if (!temDuplicidade(objCliente, "Cadastrar"))
{
db = ServidorSingleton.obterServidor().OpenClient();
db.Store(objCliente);
db.Commit();
return true;
}
else {
return false;
}
}
catch(Exception e)
{
throw new Exception("Erro cadastrando o cliente :" + e.Message);
}
finally {
db.Close();
db.Dispose();
}
}
示例3: SetUp
public void SetUp()
{
_filePath = Path.GetTempFileName();
//Db4objects.Db4o.Config.IConfiguration db4oConfiguration = Db4oFactory.Configure();
//Db4objects.Db4o.Config.IObjectClass objectClass = db4oConfiguration.ObjectClass(typeof(LanguageForm));
// objectClass.ObjectField("_writingSystemId").Indexed(true);
// objectClass.ObjectField("_form").Indexed(true);
_db = Db4oFactory.OpenFile(_filePath);
((YapStream) _db).GetNativeQueryHandler().QueryOptimizationFailure +=
OnQueryOptimizationFailure;
for (int i = 0;i < 10000;i++)
{
Entry e = new Entry();
e.name = new MultiText();
e.name._forms[0] = new LanguageForm("en", "en-" + i);
//e.name._forms[1] = new LanguageForm("fr", "fr-"+i);
e.name._singleForm = new LanguageForm("en", i.ToString());
_db.Set(e);
}
_db.Commit();
_db.Dispose();
_db = Db4oFactory.OpenFile(_filePath);
}
示例4: alterarStatus
public Boolean alterarStatus(clsStatus objAtualizar)
{
try
{
if (!temDuplicidade(objAtualizar, "Alterar"))
{
clsStatus objStatusBuscar = new clsStatus();
objStatusBuscar.Codigo = objAtualizar.Codigo;
db = ServidorSingleton.obterServidor().OpenClient();
IObjectSet leitor = db.QueryByExample(objStatusBuscar);
clsStatus objStatus = (clsStatus)leitor.Next();
objStatus.Descricao = objAtualizar.Descricao;
db.Store(objStatus);
db.Commit();
db.Close();
db.Dispose();
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw new Exception("Erro atualizando o status :" + ex.ToString());
}
}
示例5: cadastrarStatus
public Boolean cadastrarStatus(clsStatus objStatus)
{
try
{
if (!temDuplicidade(objStatus, "Cadastrar"))
{
objStatus.Codigo = obtemNovoId(); //Executa a solicitação de um novo id
db = ServidorSingleton.obterServidor().OpenClient();
db.Store(objStatus);
db.Commit();
return true;
}
else {
return false;
}
}
catch (Exception ex)
{
db.Rollback();
throw new Exception("Erro cadastrando o status :" + ex.ToString());
}
finally {
db.Close();
db.Dispose();
}
}
示例6: StoreCarCommit
public static void StoreCarCommit(IObjectContainer db)
{
Pilot pilot = new Pilot("Rubens Barrichello", 99);
Car car = new Car("BMW");
car.Pilot = pilot;
db.Store(car);
db.Commit();
}
示例7: StoreObjects
private static void StoreObjects(IObjectContainer container)
{
Random rnd = new Random();
for (int i = 0; i < 500000; i++)
{
container.Store(new DataObject(rnd));
}
container.Commit();
}
示例8: alterarFuncionario
public Boolean alterarFuncionario(Funcionario objFuncionarioAlterar)
{
try
{
if (!temDuplicidade(objFuncionarioAlterar, "Alterar"))
{
db = ServidorSingleton.obterServidor().OpenClient();
Funcionario objFuncionarioProt = FactoryClasses.criarFuncionario();
objFuncionarioProt.Codigo = objFuncionarioAlterar.Codigo;
IObjectSet leitor = db.QueryByExample(objFuncionarioProt);
if (leitor.HasNext())
{
Funcionario objFuncionario = (Funcionario)leitor.Next();
//Atribui o cargo
IObjectSet leitorCargo = db.QueryByExample(objFuncionarioAlterar.Cargo);
if (leitorCargo.HasNext())
{
Cargo objCargo = (Cargo)leitorCargo.Next();
objFuncionario.Cargo = objCargo;
}
leitorCargo = null;
objFuncionario.DataAdmissao = objFuncionarioAlterar.DataAdmissao;
objFuncionario.DataDemissao = objFuncionarioAlterar.DataDemissao;
objFuncionario.Email = objFuncionarioAlterar.Email;
objFuncionario.Login = objFuncionarioAlterar.Login;
objFuncionario.Nome = objFuncionarioAlterar.Nome;
objFuncionario.Senha = objFuncionarioAlterar.Senha;
objFuncionario.Telefone = objFuncionarioAlterar.Telefone;
db.Store(objFuncionario);
db.Commit();
leitor = null;
return true;
}
else
{
leitor = null;
return false;
}
}
else
{
return false;
}
}
catch (Exception ex)
{
db.Rollback();
throw new Exception("Erro atualizando o funcionario :" + ex.ToString());
}
finally
{
db.Close();
db.Dispose();
}
}
示例9: RollbackChanges
private static void RollbackChanges(IObjectContainer container)
{
// #example: Commit changes
container.Store(new Pilot("John"));
container.Store(new Pilot("Joanna"));
container.Commit();
// #end example
}
示例10: TryToFragmentDatabase
private static void TryToFragmentDatabase(IObjectContainer container)
{
while (!Console.KeyAvailable)
{
Random rnd = new Random();
StoreData(container, rnd);
DeleteData(container, rnd);
container.Commit();
}
}
示例11: WorkWithObjects
private static void WorkWithObjects(IObjectContainer container)
{
while (!Console.KeyAvailable)
{
Random rnd = new Random();
StoreData(container, rnd);
DeleteData(container, rnd);
container.Commit();
}
}
示例12: Setup
public static void Setup()
{
if(File.Exists(Constants.DatabasePath))
{
File.Delete(Constants.DatabasePath);
}
_db = Db4oFactory.OpenFile(Constants.DatabasePath);
var settings = new Settings();
settings.ScreenName = "detroitpro";
_db.Store(settings);
_db.Commit();
}
示例13: atualizarSolicitacao
public Boolean atualizarSolicitacao(SolicitacaoMateriais objSolicitacao)
{
SolicitacaoMateriais objSolicitacaoProt = FactoryClasses.criarSolicitacaoMateriais();
objSolicitacaoProt.Codigo = objSolicitacao.Codigo;
try
{
db = ServidorSingleton.obterServidor().OpenClient();
IObjectSet leitor = db.QueryByExample(objSolicitacaoProt);
if (leitor.HasNext())
{
SolicitacaoMateriais objSolicitacaoCache = (SolicitacaoMateriais)leitor.Next();
objSolicitacaoCache.GestorObra = objSolicitacao.GestorObra;
int i = 0;
foreach (Materiais material in objSolicitacaoCache.Materiais) {
if (material.Codigo == objSolicitacao.Codigo) {
Fornecedor objFornecedor = FactoryClasses.criarFornecedor();
objFornecedor.Codigo = objSolicitacao.Materiais[i].Fornecedor.Codigo;
material.Fornecedor = objFornecedor;
}
i++;
}
objSolicitacaoCache.Materiais = objSolicitacao.Materiais;
objSolicitacaoCache.Status = objSolicitacao.Status;
objSolicitacaoCache.DataEntrega = objSolicitacao.DataEntrega;
objSolicitacaoCache.NumNotaFiscal = objSolicitacao.NumNotaFiscal;
objSolicitacaoCache.DataEntrega = objSolicitacao.DataEntrega;
objSolicitacaoCache.Msg = objSolicitacao.Msg;
db.Store(objSolicitacaoCache);
db.Commit();
db.Close();
db.Dispose();
return true;
}
else
{
db.Close();
db.Dispose();
return false;
}
}
catch (Exception e)
{
db.Rollback();
db.Close();
db.Dispose();
throw new Exception("Erro atualizando a solicitação :" + e.Message);
}
}
示例14: alterarFilme
public Boolean alterarFilme(clsFilme objAtualizar)
{
try
{
db = ServidorSingleton.obterServidor().OpenClient();
clsFilme filmeBuscar = new clsFilme();
filmeBuscar.Codigo = objAtualizar.Codigo;
IObjectSet leitor = db.QueryByExample(filmeBuscar);
if (leitor.HasNext())
{
clsFilme objFilme = (clsFilme)leitor.Next();
objFilme.Ano = objAtualizar.Ano;
objFilme.Avaliacao = objAtualizar.Avaliacao;
objFilme.TituloBr = objAtualizar.TituloBr;
objFilme.TituloOriginal = objAtualizar.TituloOriginal;
IObjectSet leitorGenero = db.QueryByExample(objAtualizar.Genero);
if (leitorGenero.HasNext()) {
objFilme.Genero = (clsGenero)leitorGenero.Next();
}
leitorGenero = null;
IObjectSet leitorStatus = db.QueryByExample(objAtualizar.Status);
if (leitorStatus.HasNext())
{
objFilme.Status = (clsStatus)leitorStatus.Next();
}
leitorStatus = null;
db.Store(objFilme);
db.Commit();
return true;
}
else
{
return false;
}
leitor = null;
}
catch (Exception ex)
{
db.Rollback();
throw new Exception("Erro atualizando o filme :" + ex.ToString());
}
finally {
db.Close();
db.Dispose();
}
}
示例15: DeleteAndReadd
private void DeleteAndReadd(IObjectContainer db, Collection4 removed)
{
var removeIter = removed.GetEnumerator();
while (removeIter.MoveNext())
{
db.Delete(removeIter.Current);
}
db.Commit();
var readdIter = removed.GetEnumerator();
while (readdIter.MoveNext())
{
db.Store(readdIter.Current);
}
db.Commit();
}