Questions tagged [nhibernate-queryover]

0

votes
0

answer
3

Views

NHibernate QueryOver syntax with multiple tables

I have some problems with NHibernate QueryOver Syntax. I am not able to convert the following SQL to NHibernate QueryOver Statement: "select m.* " + "from authmodule m inner join authmoduleassignment ma on m.Id = ma.module_id " + "inner join authroleassignment ra on ma.role_id = ra.role_id " + "inn...
1

votes
3

answer
96

Views

How to do more than one level projection in query over?

I tired this respondentSanctionSubquery = respondentSanctionSubquery.Select(x => x.Respondent.Incident.Id); but i got this exception : i have 3 entities not 2 entities : class Respondent { public IncidentObj{get;set;} } class Incident { public int Id{get;set;} } class RespondentSanction { public Re...
sohaib
1

votes
1

answer
620

Views

Nhibernate Group By and Alias To Bean

I have been struggling to get an old query translated to Nhibernate. We are upgrading an old project from Nhibernate 2 to the latest version. I am using the QueryOver syntax since Linq wasn't an option because of the complexity of the queries (advice of a colleague). I want to query the DB (Oracle)...
Beejee
1

votes
1

answer
641

Views

NHibernate where restrictions with an alias

I'm trying to do a query where someProperty.contains(string) || otherProperty.contains(string) so I found the following: .where( restrictions.on(x => x.property).IsLike(string) || restrictions.on(x => x.prop2).IsLike(string) ) however, I have an alias before this where for one of the properties for...
duxfox--
2

votes
1

answer
5.9k

Views

NHibernate QueryOver subquery to return only newest record

I have a query in Nhibernate QueryOver which brings back a collection of episode objects (episode being a spell of care) which in turn has a collection of episode statuses as a property of each episode. However I want to change this so that each episode only brings back the latest status update for...
B-Lat
1

votes
1

answer
553

Views

Order by date column in nhibernate is working as order by string

I am trying to sorty data using date column but the column is sorting as string not as date. how to solve this problem? Code: var projection = Projections.SqlFunction("lower", NHibernateUtil.String,Projections.Property("datecolumn1")); if(order="desc")queryOver = queryOver.OrderBy(projection).Desc;...
Vetrivel mp
1

votes
2

answer
1.5k

Views

How do I express a query containing a WHERE..IN subquery using NHibernate's QueryOver API?

I have an object model where an Order contains many LineItems, and each LineItem has an associated Product. In the object model, these are one-way associations -- a LineItem does not know anything about its Order. I want to query for orders that contain a line item with a product name matching a str...
Brant Bobby
1

votes
1

answer
3.5k

Views

Nhibernate Where Exists queryOver

I have the following objects public class Document { public Guid Id { get; set; } public ISet Tags { get; set;} ... } public class Tag { public Guid Id { get; set;} } This is a many to many relationship but I do not have an intermediate DocumentTag object. I am trying to use QueryOver syntax to r...
Vadim Rybak
2

votes
2

answer
764

Views

NHibernate QueryOver NullReferenceException

I have following QueryOver which throws NullReferenceException when newExam.ActiveTo is null (ActiveTo type is DateTime?) Exam examAlias = null; examsInSameTime = session.QueryOver(() => examAlias) .Where(() => examAlias.ActiveTo == null && newExam.ActiveTo == null) .Future(); When I rewrote query t...
Minarja
6

votes
3

answer
976

Views

GroupBy SqlFunction on QueryOver

I have a list of all distinct account name prefixes (a-z) which I acquire using var accounts = this.SessionManager.GetActiveSession().QueryOver(); var q = accounts.Select(Projections.Distinct( Projections.SqlFunction("substring", NHibernateUtil.String, Projections.Property("Name"), Projections.Con...
JConstantine
7

votes
2

answer
7.3k

Views

Nhibernate QueryOver. OrderBy using strings property names.

I'm refactoring old-style query CreateCriteria() to QueryOver(). My Wcf service gets string PropertyName to order queries results. For IQueryable I use Dynamic LINQ to do such ordering, for CreateCriteria() - AddOrder(). IList result = GetSession() .QueryOver(() => activity) .JoinAlias(() => activi...
Ievgen Martynov
6

votes
1

answer
4.6k

Views

QueryOver statement for selecting N rows with descending DateTime order

I am trying to write QueryOver statement for selecting N rows in the descending time order. session.QueryOver().Take(10).OrderBy(x=>x.DateInserted); Unfortunately this is not at all working. Is there any way to sort it out?
viento
3

votes
1

answer
865

Views

NHibernate COALESCE issue

I am trying to express the following SQL query with NHibernate DECLARE @date DATETIME = NULL; SELECT ER.Id , ER.DocumentDate FROM ExpenseReport ER WHERE ER.PeriodFrom >= COALESCE(@date, ER.PeriodFrom) OR ER.PeriodTo
Dimi Takis
6

votes
1

answer
6.5k

Views

Nhibernate could not resolve property exception when using QueryOver, works on QueryAll

I have the following problem Basically I have the 2 snippets below: var contactAssociation = session.QueryOver(() => contactAssociationAlias) .Where(() => contactAssociationAlias.Contact.ID == careGiverId && contactAssociationAlias.Client.ID == clientKey) .Where(() => contactAssociationAlias.AclRo...
Para
2

votes
1

answer
1.7k

Views

nHibernate QueryOver build programmatically?

Hello is there an option to build queryover from nhibernate programmatically from code ? I don't know how many restriction will be , how many tables i'm building automat that will make queryover from a list of objects.
Endiss
2

votes
2

answer
2.8k

Views

Fetch entire entity with joined entities from database and avoid lazy load, nHibernate QueryOver

I have an entity like this: public class Employment { public virtual Company Company {get; set;} public virtual Person Person {get; set;} public virtual string Description {get; set;} } providing a relationship between two other entities. They have corresponding DTO's and I want to return a result s...
Oskar Emil
2

votes
1

answer
6.2k

Views

NHibernate QueryOver and Collection Filtering

Simple example of my class: public class Post { public IEnumerable Tags { get; set; } } User checks few interested tags for filtering Post list. I need to filter all post by selected tags like: Session.QueryOver() .WhereRestrictionOn(x => x.Tags) .IsIn(criterion.InterestedTags.ToList()) .List(); Exc...
2

votes
1

answer
302

Views

NHibernate - QueryOver Child rows as comma separated values

I have to write a query where for each vendor I have to read vendor's contact numbers from VendorContact but instead in rows, one row for each unique vendor and one columns for each phone number as comma separated string in main result. This can be done easily in plain SQL but I have to do it in Que...
Builder
11

votes
1

answer
5.6k

Views

simple QueryOver : Unrecognised method call

I have a simple QueryOver var q = SessionInstance.QueryOver().Where(p => p.Number.Equals(number)); Number field type is int. This query has a runtime error by this message: Unrecognised method call: System.Int32:Boolean Equals(Int32)
Ehsan
2

votes
1

answer
62

Views

How can I make a query that returns objects who contain all ids from list

I have two objects : Profile and Tags. Each profile can contain multiple tags. On my search page I can select multiple tags to search on. Now I want a query that get all profiles that have all the selected tags. So if I use WhereRestrictionOn().IsIn() I get profiles which contains at least 1 of the...
Nanou Ponette
2

votes
1

answer
1.3k

Views

NHibernate TOP N Rows Per Group

Here is my domain: public class ForumTheme { public virtual String Name { get;set; } } public class ForumTopic { public virtual IList Themes { get;set; } } public class ForumMessage { public virtual IList Topics { get;set; } public virtual DateTime DatePosted { get; set; } } What i want to get is: T...
Auk
5

votes
3

answer
2.9k

Views

NHibernate QueryOver group by without selecting the grouped by column

Having a query like the following: var subquery = SessionFactory.GetCurrentSession() .QueryOver() .Where(_ => _.SomeOtherEntity.Id == someId) .SelectList(list => list .SelectGroup(x => x.SomeGroupByProperty) .SelectMax(x => x.MaxPerGroupProperty)) .List(); The generated sql is selecting both SomeGro...
3

votes
2

answer
5k

Views

NHibernate - filtering out results based on child-property

I have this code fetching all enabled Groups with their children. The problem I have is that the children can also be disabled but I can't get fluent nhibernate to only fetch groups where all childrens are enabled. I assume this is possible but how? public class Group { public bool IsDisabled { get;...
Fredrik C
4

votes
2

answer
4.9k

Views

How to add groupby in query over nhibernate?

How can I add groupby Id to this nhibernate code because I'm new with it and there is many way but none work for me. .Select(Projections.Sum(() => ServiceOrderItem.WorkTime), Projections.ProjectionList().Add(Projections.Property( () => ServiceOrder.Id).WithAlias(() => TechnicianWorkTime.Id)) ) Ther...
Endiss
4

votes
1

answer
14.3k

Views

Join multiple tables with NHibernate and QueryOver

I have this tables: Person -> PersonFavorites, PersonCompany PersonCompany -> Company I have now to do the following select with NHibernate and QueryOver: select * from Person inner join PersonFavorites on Person.Id = PersonFavorites.PersonId inner join PersonCompany on Person.Id = PersonCompany.P...
BennoDual
4

votes
1

answer
903

Views

NHibernate QueryOver on an IUserType

First let me apologize a bit for the length of this post, it's mostly code though so I hope you all bear with me! I have a scenario in dealing with a legacy database, where I needed to write an IUserType using NHibernate 3.2 to take a 2 character "status" field and return a Boolean value from it. Th...
NYCChris
3

votes
1

answer
698

Views

SQL Where Expression in QueryOver API

I am using the QueryOverApi, trying to use a SQL Expression in the where clause. I have basically: var query = CurrentSession.QueryOver(() => appt) .JoinAlias(() => appt.Work, () => work) .JoinAlias(()=>appt.Contact,()=>ct) .JoinAlias (()=>ct.Tags,()=>tag) .Where(Expression.Sql("(ct2_.OrganizationId...
JoshBerke
2

votes
1

answer
4.1k

Views

NHibernate QueryOver Restrinctions on a variable

I've a little problem: I would insert a condition into my QueryOver that checks also the variable value. Something like this: var qOver = QueryOver.Of(() => myMod) .JoinAlias(() => myMod.SubMod, () => subMod, JoinType.LeftOuterJoin) .Where(Restrictions.Or( Restrictions.On(() => myMod.ID).IsIn(MyIDLi...
Faber
3

votes
2

answer
1.5k

Views

NHibernate equivalent of SQL IsNull(column, 'defaultValue')

How can I use NHibernate (preferably QueryOver syntax) to get the following SQL SELECT this_.Name as_, count(IsNull(this_.Name , 'UNKNOWN') ) as NameCount FROM...
getit
2

votes
0

answer
150

Views

How to project value object (component) into a DTO?

Is it possible to transform component into a dto when creating projections via SelectList. I have a value object Name, and I need to project it into a Dto NameInfo. Below is the query. I need a step here on this line .Select(c=> coveredInsured.Name).WithAlias(()=>info.Name) something along the line...
epitka
2

votes
3

answer
1.4k

Views

QueryOver error : Unrecognised method call in expression value

I have a query by QueryOver in Nhibernate3.1 var q = SessionInstance.QueryOver() .Where(x => IsActive(x.PersonType) == true); return q.List(); By this method: private bool IsActive(PersonType type) { if(type == PersonType.Employee return true; else return false; } Now it has a runtime error by this...
Ehsan
2

votes
1

answer
462

Views

Mock NHibernate IQueryOverOrderBuilder object

So I'm trying to write some test cases for my business logic layer. I've already mocked up my data access layer (which returns NHibernate IQueryOver objects). I created a MockQueryOver class that implements the IQueryOver interface because I chain functions in the business logic layer so creating a...
Andrew Hassan
2

votes
0

answer
361

Views

Is it possible to order by expression of func in NHibernate Query Over?

I am currently using a decoupled structure in the project i'm developing on. I have view models that i list and sort on, and thus the orderby property when sorting is of a view model name. To translate this to something i can use to query and sort the mapped model i am using mapping classes that map...
carl
2

votes
1

answer
1.2k

Views

Select or SelectList: I Want to include the entire entity

I am querying a list of objects, and then correlating them with a subquery. I want to return the results of the subquery, as well as the root entity. But I can't figure out how to actually return the root entity, I can only return individual properties of it. Specifically, this works: this.Session....
Andrew Shepherd
2

votes
1

answer
595

Views

QueryOver order by joined alias: The multi-part identifier could not be bound

I am having problems with a query: Company thirdParty = null; var thirdParties = Session.QueryOver() .JoinAlias(x => x.Company, () => thirdParty) .WhereRestrictionOn(x => x.Domain.Id) .IsIn(domainIds) .OrderBy(() => thirdParty.Name).Asc .Select(x => x.Company) .List(); The ThirdpartyCompany entity l...
carl
3

votes
2

answer
324

Views

NHibernate RowCountInt64 returns wrong count with transformed query

I am experiencing a weird error while executing an NHibernate Query. I have a query of type IQueryOver which is filtered and transformed (using DistinctRootEntity, which i am guessing is causing the problem). I create the query like this: List companyList = /* some guids */ Company company = null; v...
carl
5

votes
6

answer
5.1k

Views

Nhibernate QueryOver don't get latest database changes

I am trying get a record updated from database with QueryOver. My code initially creates an entity and saves in database, then the same record is updated on database externally( from other program, manually or the same program running in other machine), and when I call queryOver filtering by the fie...
Carlos
3

votes
1

answer
1k

Views

NHibernate: Could not resolve property: empAlias

My purpose is to find Employee information in Project that have ProjectNumber > 2 This is my query: List empList = new List(); using (ISession mySession = SessionFactory().OpenSession()) { using (ITransaction myTransaction = mySession.BeginTransaction()) { EmployeeDAO empDaoAlias = null; Employee em...
haipham23
4

votes
1

answer
2.9k

Views

How do I do a String.IsNullOrEmpty() test in an NHibernate Queryover where clause?

I hit a situation today where a field in our legacy db that should never be empty... was empty. I am using NHibernate 3.2 against this database and the queries that are affected are written in QueryOver. My current query is this return Session .QueryOver() .Where(fg => fg.Owner.Id == Token.OwnerId &...
NYCChris
23

votes
1

answer
10.1k

Views

QueryOver Or with Subquery

IHave the following NHibernate query using a subquery: NHContext.Session.QueryOver() .WithSubquery.WhereProperty(x => x.ItemId).In(QueryOver.Of().Where(x => x.AFlag).Select(x => x.ItemId)) .WithSubquery.WhereProperty(x => x.ItemId).In(QueryOver.Of().Where(x => x.AFlag).Select(x => x.Item)) .Future...
Gunner

View additional questions

Смотреть фильмы онлайн бабушка легкого поведения 2 фильм бесплатно