queryover

NHibernate - QueryOver criteria appearing in Where instead in Having clause, error

℡╲_俬逩灬. 提交于 2019-11-28 10:37:14
问题 I have a problem in QueryOver where using Group by and have some criteria in where clause. Want to move some criteria with SUM() values in Having clause but every time it appears in Where clause and result in error. **Error** ="*An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference*" Conjunction conjunction = Restrictions.Conjunction(); Conjunction havingconjun =

NHibernate QueryOver how to join on non declared relationship

Deadly 提交于 2019-11-28 10:24:51
How to do the following join to return Users who have access to a Company given a company id. The problem is there is no explicit relationship using a User object between UserAccess and User they simply join on the string property Username: User(Username, Name) UserAccess(Username, Company) Company(Id) Session.QueryOver<Company>() .Where(c => c.Id == companyId) .JoinQueryOver<UserCompanyAccess>(u => u.UserAccessList) .JoinQueryOver<User>(u => **Nope no property, just a string** could be done with a subquery var subquery = QueryOver.Of<Company>() .Where(c => c.Id == companyId) .JoinQueryOver

How to write this linq query with Criteria or QueryOver API

﹥>﹥吖頭↗ 提交于 2019-11-28 05:37:28
问题 Is it possible to convert this code at below, written by using Query(linq) api to Criteria or QueryOver API in NHibernate? I'm using this to format data into DTO's also it works with just one round-trip to db. Note: I tried transformers.aliastobean but I can only use one transformer at a time. Is it possible to use multiple transformer in one query? from entityType in Provider.GetSession().Query<crmEntityType>() .Fetch(x => x.Association) .Fetch(x => x.Fields) .AsEnumerable() where

Adding conditions to outer joins with NHibernate ICriteria/QueryOver query

强颜欢笑 提交于 2019-11-28 02:06:59
问题 Is there a way to specify additional conditions on outer joins in NHibernate when querying using QueryOver or ICriteria? I need some extra conditions on the outer join-ed table, but NHibernate always adds them to the WHERE clause at the end - which does not get the correct behaviour (see http://weblogs.sqlteam.com/jeffs/archive/2007/05/14/criteria-on-outer-joined-tables.aspx). I can't seem to find any way to do this using Criteria or the QueryOver syntax... Thanks 回答1: You probably figure out

ToRowCountQuery seems to ignore groupings

↘锁芯ラ 提交于 2019-11-28 02:04:04
I'm trying to create a rowcount-query from a regular query, but the resulting SQL seems to lack the GROUP BY resulting in a wrong count. Does anyone know what I'm doing wrong. First the queries: var query = Session.QueryOver<InkoopFactuurListItem>() .Where(i => i.KlantId == Klant.Id) .AndRestrictionOn(i => i.Status).IsIn(statussen) .SelectList(list => list .SelectGroup(h => h.Id).WithAlias(() => dto.Id) .SelectGroup(h => h.Banknummer).WithAlias(() => dto.Banknummer) .SelectGroup(h => h.CrediteurNaam).WithAlias(() => dto.CrediteurNaam) .SelectGroup(h => h.DienstType).WithAlias(() => dto

How to “Select” with nhibernate queryover

淺唱寂寞╮ 提交于 2019-11-27 20:23:15
问题 I want to use query over to give me back an object public class TaskMap : ClassMap<Task> { public TaskMap() { Table("Tasks"); Id(x => x.TaskId); Map(x => x.TaskName).NvarcharWithMaxSize().Not.Nullable(); Map(x => x.Description).NvarcharWithMaxSize(); Map(x => x.DueDate).Not.Nullable(); HasMany(x => x.PersonalTaskReminders).Inverse(); HasMany(x => x.TaskReminders).Inverse(); References(x => x.Course).Not.Nullable(); HasMany(x => x.CompletedTasks); } } [Serializable()] public class Task {

NHibernate QueryOver with ManytoMany

杀马特。学长 韩版系。学妹 提交于 2019-11-27 18:45:48
问题 I'm in the process of learning QueryOver, but I can't for my life figure out how to do simple many to many queries. I've written the following: var result = Session.CreateCriteria(typeof (Product)) .CreateAlias("Categories", "categories") .Add(Property.ForName("categories.Id").Eq(categoryId)) .List<Product>(); This achieves the desired result. Basically I have Product > ProductCategory < Category ProductCategory just has ProductId / CategoryId, and I'm trying to select all the products in a

nhibernate queryover join with subquery to get aggregate column

ぃ、小莉子 提交于 2019-11-27 17:59:52
问题 I have been searching for several hours now how to do this, but can't seem to find anything to help me. Here is the database model: This is the SQL query I am trying to run: SELECT b.*, a.Assignments FROM Branch b LEFT JOIN ( SELECT b.BranchID , COUNT(ab.BranchID) AS Assignments FROM Branch b LEFT JOIN AssignmentBranch ab ON b.BranchID = ab.BranchID GROUP BY b.BranchID ) a ON b.BranchID = a.BranchID So, basically, I want to return a list of branches and a new column that represents the number

queryover and (x like 'a' or y like 'a')

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 17:57:58
Hi Is there any elegant way of combining 'like' and 'or' when i'm using queryover API? for 'like' there is something like: query.WhereRestrictionOn(x=>x.Code).IsLike(codePart) for 'or' i can do something like: query.Where( x=>x.Code == codePart || x.Description== codePart) but how can I create a query like this: select * from n where code like '%abc%' or description like '%abc%' query.Where(Restrictions.On<Type>(x => x.Code).IsLike(codePart) || Restrictions.On<Type>(x => x.Description).IsLike(codePart)) You could use the NHibernate Disjunction class to do this in a more elegant (IMHO) fashion:

How to join Two tables of two non relashinship defined columns using Nhibernate QueryOver

爱⌒轻易说出口 提交于 2019-11-27 16:27:09
Using NHibernate QueryOver , I want to join two tables using two columns which are not defined in the mapping as a relationship. E.g. This is not my exact scenario but this can explain that Tables: Employee(Id, Name, DepartmentId, SomeCode,Address) Department (Id, Name, ,Code) Select SELECT * FROM EMPLOYEE E JOIN DEPARTMENT D ON D.Code = E.SomeCode Can someone please tell me how to do this query using NHibernate QueryOver . Note that "SomeCode" in Employee and "Code" in Department are not defined as a relationship. DepartmentId is the foreign key and I can join these using JoinAlias but I want