queryover

Nhibernate subquery with multiple columns join

扶醉桌前 提交于 2020-03-12 05:47:54
问题 I have database structure for Plans and PlanVersions in following relationship: +------+ +-------------+ | Plan | --------------> | PlanVersion | +------+ 1 (1..n) +-------------+ PlanVersion is version table tracking all version changes and it have ActiveFromData and ActiveToData columns show us when was this version active. Plan also can have SubPlans which can change in time so PlanVersion also have ParrentPlanId column which tell us what was current subplan for version. What i want is to

NHibernate- QueryOver using base classes?

大兔子大兔子 提交于 2020-01-25 01:23:05
问题 Right now I'm using the Criteria API and loving it, but it would be even better if I could make the switch to the QueryOver API. However, my setup is a little strange. In order to partition data into tables, I have one base abstract class: Listing and a number of classes which inherit from that: Listing_UK Listing_US etc. With the criteria API, I can do something like: Type t = typeof(Listing_UK); if (condition) t = typeof(Listing_US); DbSession.CreateCriteria(t) .Add(Restriction.Eq("field"

Can I use SQL functions in NHibernate QueryOver?

不羁的心 提交于 2020-01-12 14:12:31
问题 I have been searching the internet and can't find an example on how to use the queryover of nhibernate 3.0 For example I would like to use the string functions on the where clause of the queryover ex: var item = Query.Where(x => x.Name.ToLower() == name.ToLower()).FirstOrDefault(); But this doesn't work, because nhibernate can't understand the ToLower, so how can extend the dialect in a way that this becomes possible? 回答1: session.QueryOver<Foo>() .Where(Restrictions.Eq( Projections

Nhibernate migrate ICriteria to QueryOver

时光毁灭记忆、已成空白 提交于 2020-01-05 05:41:47
问题 We are using ICriteria and now we would like to switch to more readable QueryOver in Nhibernate Can someone give me a hint how to convert this generic pagination logic for Icriteria to QueryOver? public static PagedList<T> PagedList<T>(this ICriteria criteria, ISession session, int pageIndex, int pageSize) where T : class { if (pageIndex < 0) pageIndex = 0; var countCrit = (ICriteria)criteria.Clone(); countCrit.ClearOrders(); // so we don’t have missing group by exceptions var results =

NHibernate QueryOver With Paging While Selecting Top 1 Of SubQuery

╄→尐↘猪︶ㄣ 提交于 2020-01-04 05:25:07
问题 I have 2 entities (These are broken down to question to be simpler): Entity A public class EntityA { protected IList<EntityB> _bList = new List<EntityB>(); virtual public int Id { get; set; } virtual public int ExtId { get; set; } public virtual void AddB(EntityB b) { if (!_bList.Contains(b)) _bList.Add(b); b.A = this; b.ExtId = this.ExtId; } public virtual void RemoveB(EntityB b) { _bList.Remove(b); } public virtual IList<EntityB> BList { get { return _bList.ToList().AsReadOnly(); } } }

Issues with NHibernate QueryOver and Subqueries

陌路散爱 提交于 2020-01-04 04:18:22
问题 I have the following model: public class User { public virtual int Id { get; set; } public virtual string Username { get; set; } public virtual string Password { get; set; } public virtual string Email { get; set; } public IList<SubmissionNote> Notes { get;set; } } public class SubmissionNote { public virtual Int64 Id { get; set; } public virtual string Text { get; set; } public virtual DateTime CreatedOn { get; set; } public virtual User Creator { get; set; } public virtual Submission

Nhibernate - lists on SelectList

久未见 提交于 2020-01-02 23:16:29
问题 I'm using NHibernate and I have come across a problem. I have this entities in my project: Client: public class Client { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string UserName { get; set; } public virtual string Password { get; set; } public virtual IList<Date> Dates { get; set; } public Client() { Dates = new List<Date>(); } } Date: public class Date { public virtual int Id { get; set; } public virtual DateTime DateTime { get; set; }

Nhibernate - lists on SelectList

浪子不回头ぞ 提交于 2020-01-02 23:16:09
问题 I'm using NHibernate and I have come across a problem. I have this entities in my project: Client: public class Client { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string UserName { get; set; } public virtual string Password { get; set; } public virtual IList<Date> Dates { get; set; } public Client() { Dates = new List<Date>(); } } Date: public class Date { public virtual int Id { get; set; } public virtual DateTime DateTime { get; set; }

Disjunction on QueryOver<T> always refers to root entity

戏子无情 提交于 2020-01-02 06:14:10
问题 I'm trying to add a certain numbers of OR conditions using disjunction on X number of entities that implements a certain interface containing date information. My problem is that when the SQL is generated all my disjunction conditions points to the root entity of my QueryOver. I have created a generic method to add my conditions public static QueryOver<T,T2> AddChangedCondition<T,T2>(this QueryOver<T,T2> query, DateTime from, DateTime to, Disjunction disjunction) where T2 : IHaveDate { if

How to do subqueries in nhibernate?

非 Y 不嫁゛ 提交于 2019-12-31 20:14:14
问题 I need to do a subquery on a sub collection but I can't get it to work. I tried this Task tAlias = null; List<Task> result = session.QueryOver<Task>(() => tAlias) .Where(Restrictions.In(Projections.Property(() => tAlias.Course.Id), courseIds)) .WithSubquery.WhereExists(QueryOver.Of<CompletedTask>().Where(x => x.Student.StudentId == settings.StudentId)) ().ToList(); Yet I get Cannot use subqueries on a criteria without a projection. 回答1: session.QueryOver<Task>(() => tAlias)