当前位置: 首页>>代码示例>>C#>>正文


C# IObjectContainer.QueryByExample方法代码示例

本文整理汇总了C#中IObjectContainer.QueryByExample方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectContainer.QueryByExample方法的具体用法?C# IObjectContainer.QueryByExample怎么用?C# IObjectContainer.QueryByExample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObjectContainer的用法示例。


在下文中一共展示了IObjectContainer.QueryByExample方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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();
            }
        }
开发者ID:fbsharp,项目名称:Projetos,代码行数:57,代码来源:FuncionarioDAO.cs

示例2: 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();
            }
        }
开发者ID:fbsharp,项目名称:Projetos,代码行数:49,代码来源:FilmeDAO.cs

示例3: 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());
            }
        }
开发者ID:fbsharp,项目名称:Projetos,代码行数:30,代码来源:StatusDAO.cs

示例4: EditAuthorWindow

        public EditAuthorWindow(ref IObjectContainer db, Author author)
        {
            InitializeComponent();
            _db = db;
            _author = author;
            Title += _author.LastName;

            // fill form
            LastNameTxtBox.Text = _author.LastName;
            BirthDatepicker.SelectedDate = _author.BirthDate;

            var collection = new ObservableCollection<PublicationEditableGrid>();
            foreach (var item in _db.QueryByExample(new Publication()))
            {
                var itemPub = item as Publication;
                collection.Add(new PublicationEditableGrid()
                {
                    Title = itemPub.Title,
                    Year = itemPub.Year,
                    IsAuthor = _author.Publications.Contains(itemPub)
                });
            }
            publicationsGrid.ItemsSource = collection.OrderBy(x => x.Title);
            publicationsGrid.SelectedItem = null;
        }
开发者ID:jacekk,项目名称:db4o-library,代码行数:25,代码来源:EditAuthorWindow.xaml.cs

示例5: ClearDatabase

		public static void ClearDatabase(IObjectContainer db)
		{
			IObjectSet result = db.QueryByExample(typeof(Pilot));
			while (result.HasNext())
			{
				db.Delete(result.Next());
			}
		}
开发者ID:erdincay,项目名称:db4o,代码行数:8,代码来源:NQExample.cs

示例6: RetrieveAllSnapshots

 public static void RetrieveAllSnapshots(IObjectContainer db)
 {
     IObjectSet result = db.QueryByExample(typeof(SensorReadout));
     while (result.HasNext())
     {
         Console.WriteLine(result.Next());
     }
 }
开发者ID:Galigator,项目名称:db4o,代码行数:8,代码来源:DeepExample.cs

示例7: AllObjectsOfAType

        private static void AllObjectsOfAType(IObjectContainer container)
        {
            // #example: All objects of a type by passing the type
            IList result = container.QueryByExample(typeof (Pilot));
            // #end example

            ListResult(result);
        }
开发者ID:Galigator,项目名称:db4o,代码行数:8,代码来源:QueryByExamples.cs

示例8: AllObjects

        private static void AllObjects(IObjectContainer container)
        {
            // #example: All objects
            IList result = container.QueryByExample(null);
            // #end example

            ListResult(result);
        }
开发者ID:Galigator,项目名称:db4o,代码行数:8,代码来源:QueryByExamples.cs

示例9: DeleteAll

		public static void DeleteAll(IObjectContainer db) 
		{
			IObjectSet result = db.QueryByExample(typeof(Object));
			foreach (object item in result)
			{
				db.Delete(item);
			}
		}		
开发者ID:erdincay,项目名称:db4o,代码行数:8,代码来源:Util.cs

示例10: RetrieveCarByPilotQBE

 public static void RetrieveCarByPilotQBE(IObjectContainer db)
 {
     Pilot pilotproto = new Pilot("Rubens Barrichello", 0);
     Car carproto = new Car(null);
     carproto.Pilot = pilotproto;
     IObjectSet result = db.QueryByExample(carproto);
     ListResult(result);
 }
开发者ID:Galigator,项目名称:db4o,代码行数:8,代码来源:StructuredExample.cs

示例11: CarSnapshotRollback

 public static void CarSnapshotRollback(IObjectContainer db)
 {
     IObjectSet result = db.QueryByExample(new Car("BMW"));
     Car car = (Car)result.Next();
     car.Snapshot();
     db.Store(car);
     db.Rollback();
     Console.WriteLine(car);
 }
开发者ID:erdincay,项目名称:db4o,代码行数:9,代码来源:TransactionExample.cs

示例12: UpdatePilot

 public static void UpdatePilot(IObjectContainer db)
 {
     IObjectSet result = db.QueryByExample(new Pilot("Michael Schumacher", 0));
     Pilot found = (Pilot)result.Next();
     found.AddPoints(11);
     db.Store(found);
     Console.WriteLine("Added 11 points for {0}", found);
     RetrieveAllPilots(db);
 }
开发者ID:Galigator,项目名称:db4o,代码行数:9,代码来源:FirstStepsExample.cs

示例13: RetrieveCarQBE

		public static void RetrieveCarQBE(IObjectContainer db)
		{
			SensorReadout protoReadout = new SensorReadout(new double[] { 0.6, 0.2 }, DateTime.MinValue, null);
			IList protoHistory = new ArrayList();
			protoHistory.Add(protoReadout);
			Car protoCar = new Car(null, protoHistory);
			IObjectSet result = db.QueryByExample(protoCar);
			ListResult(result);
		}
开发者ID:Galigator,项目名称:db4o,代码行数:9,代码来源:CollectionsExample.cs

示例14: QueryForAge

        private static void QueryForAge(IObjectContainer container)
        {
            // #example: Query for 33 year old pilots
            Pilot theExample = new Pilot();
            theExample.Age = 33;
            IList result = container.QueryByExample(theExample);
            // #end example

            ListResult(result);
        }
开发者ID:Galigator,项目名称:db4o,代码行数:10,代码来源:QueryByExamples.cs

示例15: QueryForName

        private static void QueryForName(IObjectContainer container)
        {
            // #example: Query for John by example
            Pilot theExample = new Pilot();
            theExample.Name = "John";
            IList result = container.QueryByExample(theExample);
            // #end example

            ListResult(result);
        }
开发者ID:Galigator,项目名称:db4o,代码行数:10,代码来源:QueryByExamples.cs


注:本文中的IObjectContainer.QueryByExample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。