boolean in criteria query
My criteria looks like: Session.CreateCriteria(typeof(User)) .Add(Expression.Eq("IsActive", 1); Do I put 1 or True for the IsActive boolean check? (non seem to work?) what are my options? ...
My criteria looks like: Session.CreateCriteria(typeof(User)) .Add(Expression.Eq("IsActive", 1); Do I put 1 or True for the IsActive boolean check? (non seem to work?) what are my options? ...
Using Hql or criteria, how can I update many rows and set a property to false? ie. SQL would be: UPDATE UserOrders SET isDeleted = 0 -- (boolean false) WHERE uID = 234 ...
I haven't made too many changes to my project which uses NHibernate, however now all unit tests fail for any time I use hql. I get the error "Could not load file or assembly 'Antlr3.Runtime, Version=3.1.0.39271, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7' or one of its dependencies." I am still referencing the Antlr3.Runtime dll t...
My object model Person _______ public IList<Role> Roles { get; set; } public IList<Group> Groups { get; set; } Group _____ public IList<Role> Roles { get; set; } Role ____ public string Role { get; set; } So pretty much a standard roles based model, a User can exist in zero to many groups which have roles assigned to them, and can e...
I would love to thank @Stefan Steinegger and @David helped me out yesterday with many-to-many mapping. I have 3 tables which are "News", "Tags" and "News_Tags" with Many-To-Many relationship and the "News_Tags" is the link table. If I delete one of the news records, the following mappings will delete all my news records which have the...
Hi, Is it possible to map an entities properties from different database tables? Say you had the below data model... [dbo.Albums] [dbo.Songs] [dbo.Artists] AlbumID int (PK) SongID int (PK) ArtistID int (PK) AlbumName nvarchar(100) AlbumID int ArtistName nvarchar(100) . ...
hi there, I have the following code wich causes an Update on the DB as calling Commit(). using (ISession t = DBSessionManager.GetDBSessionController(Database).GetDBSession()) { using (var tx = t.BeginTransaction()) { var o = t.Linq<Appendix>(); o.Expand...
I have a scenario in a windows service type app where I need to load up to several thousand entities, perform some business logic and then save them. In regards to session management, this kind of falls outside of the usual session per call that is often discussed. Basically, in my case I certainly don't want one session for (x) thousand...
I'm storing some data using NHibernate, and I need to insert huge amount of data as a part of this action - i.e. in the same transaction. Code looks like this: using (ISession session = NHibernateHelper.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.SaveOrUpdate(something); // ... Sq...
Say I have abstract base class Animal then Dog and Cat classes. I'm mapping these via table-per-subclass (w/ discriminator). Is it possible to query Animals and also project the discriminator-value or class name? It seems I cannot project the discriminator column. I know when I list Animals, NHibernate creates the correct Animal type f...
I'm using Fluent NHibernate in one of my projects (and ASP.NET MVC application), with LINQ to query to data (using the LINQ to NHibernate libraries). The objet names are changed to protect the innocent. Let's say I have the following classes Foo, Bar, Baz, and their appropriate tables in the database (MySQL). Foo has a many-to-many re...
I'm learning NHibernate and hoping you guys could help me a bit about Tag Cloud design and solutions. I have 3 tables which are "News", "Tags" and "News_Tags" with Many-To-Many relationship and the "News_Tags" is the link table. Options: cascade="all", cascade="all-delete-orphan" If I delete one of the news records, the it will delet...
I've got an object that uses System.Version as a property. I want this object to be mapped into my table, storing the version as a string. what's the best way to go about doing this with NHibernate v1.2? public class MyClass { public Version MyVersion {get; set;} } not sure what to do with the propery mapping <property name="MyVers...
Hi all, I ve got the following setup: public class ParentEntity { public ICollection<ChildEntity> {get; set; } } public class ChildEntity { // do i need to the parent here? } I managed to save the ParentEntity and cascaded the save to the added child entities which were saved as well. But in the db table the ParentId reference...
I have this fluent mapping: sealed class WorkPostClassMap : ClassMap<WorkPost> { public WorkPostClassMap() { Not.LazyLoad(); Id(post => post.Id).GeneratedBy.Identity().UnsavedValue(0); Map(post => post.WorkDone); References(post => post.Item).Column("workItemId").Not.Nullable(); Reference...
For entity ParentEntity with a collection of type ChildEntity which contains an Order property of type int, how can the parent entity be retrieved with the child collection sorted by Order specifically through the use of the Criteria API as discussed in section 12.4 of the NHibernate docs here? I've tried using code similar to the follo...
I'm using NHibernate + Fluent to handle my database, and I've got a problem querying for data which references other data. My simple question is: Do I need to define some "BelongsTo" etc in the mappings, or is it sufficient to define references on one side (see mapping sample below)? If so - how? If not please keep reading.. Have a look...
I know this is a very basic question, but forgive me if I did something wrong. I have a Many-to-Many relationship using <set>. When I'm debugging the code I can see the data in the "set", but I'm not sure how to display the data. For example I could use "foreach" for List, but I cannot use foreach with the "ISet". In My class: ...
I'm new to NHibernate, and have seen some issues when closing sessions prematurely. I've solved this temporarily by reusing sessions instead of opening a session pr transaction. However, I was under the impression that opening sessions each time you need them was the recommended approach for session lifetime management. No? So; what is...
Situation (following are entities): public class OrderItem { ... public Order Order ... } public class Order { ... public Customer Customer .... } public class Customer { public int Id } Question: how to create criteria, which gives me all OrderItems for some Customer id? ...