NHibernate: CreateCriteria and Exists clause
How can I write the following SQL using CreateCriteria: SELECT * FROM FooBar fb WHERE EXISTS (SELECT FooBarId FROM Baz b WHERE b.FooBarId = fb.Id) ...
How can I write the following SQL using CreateCriteria: SELECT * FROM FooBar fb WHERE EXISTS (SELECT FooBarId FROM Baz b WHERE b.FooBarId = fb.Id) ...
Hello all, I want to have a centralize place to check for inserts or updates to an object, and for certain scenarios, I want to update it's parent based on the information from the child. I have the following code in my event listener: public bool OnPreInsert(PreInsertEvent @event) { UpdateCalcs(@event.Entity); ret...
criteriaCount.CreateCriteria(AdvertisementsProperties.City.ToString()) .Add(Expression.Like(CitiesProperties.Name.ToString(), query, MatchMode.Anywhere)) .Add(Expression.Like(CitiesProperties.SlovenianName.ToString(), query, MatchMode.Anywhere)) .CreateCriteria(AdvertisementsProperties.Coun...
If I want to search those students who take class "Math" and "John" is his group: shoud I use createCriteria or createAlias? Criteria: Criteria criteria = session.createCriteria(Student.class); Criteria subquery1 = criteria.createCriteria("courses", course).add(Restrictions.eq(course.name, "Math")); Criteria subquery2 = criteria.creat...
Is it possible to chose what columns I want in return from Session.CreateCriteria() ? egz.: var x = session.CreateCriteria(); x.CreateAlias("EmployeePosition", "employeePosition"); x.Add(Restrictions.Eq("employeePosition.Name", "Developer")); and is there a way to add something like "select LastName" to avoid downloading the ...
I have an entity A which HasMany entities B and entities C. All entities A, B and C have some references x,y and z which should be loaded eagerly. I want to read from the database all entities A, and load the collections of B and C eagerly using criteria API. So far, I am able to fetch the references in 'A' eagerly. But when the collec...
I'm new to NHibernate and can't figure out why these two statements generates different sql. the first one only get the ClientInformation (with Information and Client being Proxies) which is what i want. return repository .CreateQuery("from ClientInformation ci where ci.Information.IsMandatory = true and ci.Client.Id = :cl...
I've used Fluent NHibernate to hook up a store and employee class where Stores can have many employees as follows: public class Store { public virtual IList<Employee> Employees { get; set; } //other store properties } public class Employee { public virtual Store Store { get; set; } public virtual bool? SomeStatus1 { ...
Using NHibernate, I am trying to set the value of a class contained within another class. For example: public class Object { public virtual string CODE { get; set; } public virtual string INFO { get; set; } public virtual int ID { get; set; } public virtual Location location { get; set; } } public class Location ...
For every entity that I create I write a unit test that just loads one record from the database to see if the query works and the data can be set on the entity correctly. You could see this as a unit test for the basic mapping. This should also confirm that a mapping file exists for the type and is set as embedded resource. The test loo...