Questions tagged [nhibernate-criteria]

The NHibernate Criteria API allows performing dynamic, object oriented queries in NHibernate.

Using the criteria API is one way to perform queries in NHibernate. Its strength is on writing dynamic queries at runtime. It lacks some features compared to HQL, for instance creation of cross products and joining objects on arbitrary properties.

Related:

  • QueryOver is a successor of Criteria, which provides more type safety at compile time, but is still base on Criteria.
  • Linq To NHibernate once based on Criteria, but had been rewritten to use HQL in later versions.

References:

286 questions
0
votes
1 answer

Nhibernate union of queries

I am very new to Nhibernate, so this may sound silly. I have a function which receives parameters based on what I need to make queries: Public List GetResultData(SearchParams[] searchparams) {} In this case, SearchParams is my class which has…
Gurinder Raj
  • 151
  • 1
  • 6
0
votes
1 answer

Dynamically map nhibernate native result to DataSet

For reporting scenarios, specially for large records (+millions records) I decided to bypass the nhibernate object mapping! and directly map to DataSet! Here is the algorithm ICriteria criteria = _session.CreateCriteria(entityType); // Add some…
user39880
0
votes
1 answer

nHibernate self referencing table fetch many

I have a self-referencing table which I use to build my tree view. I use the following query to get the right structure: public IList GetAllTreeNodes(string userid) { var query = Session.Query() …
0
votes
1 answer

Detached Criteria for mapped collection in Hibernate

I have three tables Student, Department, Student_Detail Table Student -------------- std_id (pk) Table Student_Detail -------------- std_id (pk) Dept_ID (pk) Table Department -------------- Dept_ID (pk) The mapping for…
Krishna
  • 321
  • 1
  • 6
  • 15
0
votes
1 answer

NHibernate Criteria Filtering

I use this code to filter database records if (!string.IsNullOrEmpty(_searchCriteria.MessageType)) { var messageType = (AutotransferMessageType)Enum.Parse(typeof(AutotransferMessageType), _searchCriteria.MessageType, true); …
truslivii.lev
  • 701
  • 1
  • 8
  • 21
0
votes
2 answers

time of executing query nhibernate

i have this query in nhibernate var fdata = (from p in _session.Query() join d in _session.Query() on p.WfTaskDetail.Id equals d.Id orderby p.ActionDate descending //(order) …
0
votes
1 answer

Join Different tables using Criteria

I have two different entities, I need to join them based on a common entity property between them, but there's no path to get from the entity the Criteria is created on to the other one! Please help. Thanks --Edit-- Sorry, maybe my question was not…
Ruba
  • 867
  • 3
  • 11
  • 19
0
votes
1 answer

Specify Association Depth in Nhibernate Criteria

Okay, lets say I have A Many-To-Many, Student/Class objects. With the following mapping HasManyToMany(m => m.Classes) .Table("StudentClasses") .LazyLoad() .Cascade.None(); and query: …
Seth
  • 954
  • 1
  • 15
  • 42
0
votes
1 answer

How can I generate Nhibernate query using Criteria for the following SQL query

I have a sql query as below: SELECT * FROM USER R INNER JOIN userdepartment C ON R.id = C.userid INNER JOIN userdepartment K ON C.userid = K.userid WHERE C.departmentid = 155 AND…
0
votes
1 answer

Fluent NHibernate - Query using Criteria with filter on connecting table

I have following tables User - Primary column - Id and other detail columns Department - Primary column - Id and other detail columns UserDepartment - Primary column - Id and other columns are UserId and DepartmentId I want to find all users those…
user2534947
  • 3
  • 1
  • 3
0
votes
1 answer

NHibernate: Query by discriminator on association

My question is similar to this question. But I want to query by the discriminator of a child entity associated with a one-to-one relationship, and without knowing the exact discriminator value, i.e., by type not by string. Given an hbm like:
joniba
  • 3,339
  • 4
  • 35
  • 49
0
votes
1 answer

How to apply filter for collection property (with one to many association) within DetachedCriteria

I am facing some issues when fetching the collection with applied criteria. public class Ship { public virtual int Id { get; protected set; } public virtual string Name { get; set; } public virtual IList Structures { get;…
0
votes
1 answer

Castle Activerecord: FindAll() by children / Use Foreign key Ids in Expression

I need to query based on child objects of an ActiveRecord class (FindByFleetAndJob(), below). Normally I would use instances of the objects but in this case I don't have them, and don't want to do two visits to the database just to get objects for…
Chris Wallis
  • 1,263
  • 8
  • 20
0
votes
1 answer

NHibernate Query Generator with Fluent mappings

I was trying to find a good way to build dynamic queries with NHibernate and that lead me to NHibernate Query Generator which I like but we currently use Fluent NHibernate mappings and I wasn't sure if there was a way to use NHibernate Query…
0
votes
1 answer

How to translate a QueryOver to DetachedCriteria?

I do not wish to know why it's better to use QueryOver and that it's newer. How can I translate the following QueyOver to a DetachedCriteria: QueryOver().Where(x => x.Properties.Any(y => y.Locales.Any(l => l.Value.Name == "propName"))); I…
Adam Tal
  • 5,911
  • 4
  • 29
  • 49