Hello,
Executing the following NHibernate.Linq statement raises a "could not instantiate: Reservation001.Services.ReservationDto" NHibernate.QueryException containing an inner InvalidCast exception ("Object must implement IConvertible."):
var inOneStep = (from r in session.Linq<Models.ReservationHeader>()
select new ReservationDto(...
I have a collection of Root Entities (IList<RootEntity>) that is returned from an NHibernate call using the ICriteria API. RootEntity has a collection of child entities, lets call that IList<Child1Entity>. Child1Entity has a collection of child entities (IList<Child2Entity>), which, being the third layer, causes the Child1Entity collecti...
I have the following NHibernate DetatchedCriteria,
return DetachedCriteria.For<MMFund>()
.CreateCriteria<MMFund>(x => x.DataUniverse)
.Add<DataUniverse>(x => x.SiteId == 100)
.SetProjection(LambdaProjection.Property<MMFund>(x => x.FundId));
which is producing the following SQL:
and
this_.ShareClassReturn_ShareClassId...
Currently I have some event listeners setup to log all insert/update/delete actions that happen. I just go through the list of properties and build a string to insert into an audit table.
What I'd really like to do is get the raw SQL query that NHibernate generates. Just like what NHProf shows.
How would I do this?
...
The title basically says it all... I'm trying to specify an auto-incrementing (int) identity column using Fluent-NHibernate and MySQL. I've tried the following variations...
Id(x => x.ID).GeneratedBy.Native();
Id(x => x.ID).GeneratedBy.Identity();
Id(x => x.ID).GeneratedBy.Increment();
...and tried setting default values on eac...
Hi,
I've rammed into a huge problem. I got to these two objects:
IList<Product> products; and
Collection collection;
Both objects contains and IList<Tag> named .Tags.
I'm trying to do the this with Linq To NHibernate:
products = products.Where(p => p.Tags.Any(t => collection.Tags.Contains(t)));
This will give an exception, because ...
Dear All!
This may be a really silly question, but I've found no answer on google/bing...
If I already use NHibernate for persistence with SQL Server, why should I then create all the table-relations on the database-schema?
I'm just wondering because it seems to create all the relations, altough I already have defined them in the NHibe...
According to REST philosophy, a PUT operation should create an entity if it doesn't exist, or update it if it does. So for example, if a client does this operation:
PUT http://server/user/5?firstname=John&lastname=Doe
I should expect that a user with an ID of 5 either be created or updated.
The update case is easy with NHibernate...
I working on a project that uses NHibernate. My problem is when I'm trying to add an object that contains a list of objects I receive the following exception:
Illegal attempt to associate a collection with two open sessions from Session.Save method
I don't know what is the problem or how to solve it, please if any one can help I wi...
Using monorail and nhibernate when saving a business object to the database I am now getting the error:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Does anyone know what causes this error? I see people getting it when calling a different db driver like for oracle but I am using...
I have three classes:
Login
Role
LoginsInRoles
Login is one-many to LoginsInRoles and Role is one-many to LoginsInRoles. This is not a traditional many-many relationship because LoginsInRoles has to be a first class entity because it has additional properties that are unique to it.
I have set the cascade to delete for login and rol...
What pattern/architecture do you use in a 3-tiered application using NHibernate that needs to support retries on transaction failures, when you are using the Session-Per-Request pattern? (as ISession becomes invalid after an exception, even if this is a deadlock or timeout or livelock exception).
...
Hi All,
I've been doing some work evaluating NHibernate for an upcoming project and am working through some use cases to see how it performs. I haven't yet been able to find a way to express the following query using the Criteri API.
Two fairly basic tables (cut down for the purpose of this example)
CREATE TABLE Person
(
PersonNo ...
I'm using Fluent NHibernate to generate a database schema from .Net entity classes. I have two classes User and Permission with a many to many relationship, and Fluent NHibernate is correctly generating a junction table UsersToPermissions in the database.
As expected the junction table is storing the primary keys UserId and PermissionId...
For example I have a joined-subclass namely Foo and wanna subclass Foo?
I don't know even it's valid or not?
...
Say I've written a custom membership provider which extends System.Web.Security.MempershipProvider. This sits in its own project.
overriding the ValidateUser method looks like this:
IList<User> Users;
using (ISession sess = NHibernateHelper.GetCurrentSession())
{
Users = sess.CreateQuery("select u from User ...
I'm building a sort of domain layer and I would like to be able to implement the following methods:
[Note: ISet is a collection class which doesn't permit duplicates, according to checking using .Equals().]
public class Parent
{
public ISet Children = new HashedSet<Child>;
public void AddChild()
{
...
}
public void RemoveChild()
{
...
...
I have a parent entity with a list of child entities. When using NHibernate to retrieve a given parent with children from SQL, it works fine if there are no children OR if there are children with dates that match the where condition.
If there are children that do not match the where clause, the parent is null. I want to have the paren...
Is it possible to create a anoynmous count with nhibernate?
The below query throws the exception "No column *".
I could of course add a column name, but I'd prefer not to, because if I do, I'll have to lookup column names for 95 tables...
NHibernate.Criterion.DetachedCriteria dcIsUniqueDomainname = NHibernate.Criterion.DetachedCriteria...
I am using fluent nhibernate. This is code Loads an instance of type T from the DB based on its ID.
public T GetById(IdT id, bool shouldLock)
{
T entity;
if (shouldLock)
{
entity = (T) NHibernateSession.Load(persitentType, id, LockMode.Upgrade);
}
else
{
entity...