I have a class Child which does not have a ParentId property but has the required foreign key in the database. I am trying to get the Children using the ParentId using NHibernate but it is throwing an error saying that could not resolve property ParentId.
public class Parent
{
public int ParentId{ get; set; }
public string Na...
Hi everyone, I've been battling with this issue for a couple of days now.
I have a couple of classes in a many-to-many relationship, configured like so:
<class name="Entry" table="Entries">
<id name="Id" column="Id">
<generator class="native" />
</id>
<timestamp name="LastUpdated" column="Entry_LastUpdated" generated=...
Hello there
How can I write a unit test for CRUD using in memory database with fluent nhibernate
...
Hi,
I have the following map in my entity:
<map cascade="all-delete-orphan" inverse="true" name="ManyToMany" mutable="true" table="ManyToManyTable">
<key column="TableAId" />
<index column="EnumValueId" type="MyEnum, MyAssembly" />
<many-to-many column="TableBId" class="MyBClass, MyAssembly"/>
</map>
This creates the table fine...
Hi, I need a solution for this: How to intercept ISet.Add method so I don't need to do children.Parent=parent, but jus parent.Children.Add(children);
public class MyClass
{
public MyClass Parent;
public ISet<MyClass> Childrens;
}
I want to do this:
var mc = new MyClass();
var mc2 = new MyClass();
mc.Childrens.Add(mc2);
and not
var...
I am just a simple beginner with both NHibernate and WCF. I would like to use NHibernate as my ORM in the class library where my repositories are. I also need to use WCF to expose my business logic, and behind that my repositories, to the rest of the company.
Is there some good documentation on how to accomplish this task? Are there pit...
Hi all,
say that we have 2 entity EntityA and EntityB , with the related tables, TableA and TableB.
i have to implement this query:
select a.Id , (select count(b.Id) from TableB b where b.FKa = a.Id and b.AnotherField > 0) as TheCount
from TableA a
i'm very close to that since i wrote this code:
var subCrit = DetachedCriteria.For<...
Hi I am writing unit tests for fluent Nhibernate, when I run the test in isloation it passes, but when I run multiple tests. or run the test more than once it starts failing with the message below
System.ApplicationException : For property 'Id' expected '1' of type 'System.Int32' but got '2' of type 'System.Int32'
[TextFixture]
public ...
I have two classes:
class Parent
{
public virtual Child Child { get; set; }
}
class Child
{
public virtual IList<GrandChild> GrandChildren { get; set; }
}
I have an instance of Parent loaded from my ISession, Parent.Child is lazy loaded (NOT loaded at this point). Child.GrandChildren is also lazy loaded.
If I do this:
sess...
I am just about starting to work with NHibernate Annotations, Are there any good articles on Annotations with examples to iron out basic doubts.
...
I'm sure I've done this before but I can't recall how. I have 2 classes, say Person and Company. I'm instantiating a new Person and want to set it up so that when I save it to repository it will be associated with Company A. Company A already exists but I don't want to pull the entire thing from the DB just so I can write:
person.Com...
I have a legacy schema that contains tables with composite keys where some of the keys are of type binary(16) -- its a MD5 hash of the other columns. I am having trouble finding the right way to map this structure. The first thing I tried was to simply use byte[] as my domain type, which NHibernate quickly dismissed since byte[] does not...
I've noticed that when I evict things from the session factory, the cmd_flush counter is increased in the memcached server. This makes the caching less useful since it is reset fairly often.
Here's my code that triggers this:
session.SessionFactory.Evict(typeof(Foo));
session.SessionFactory.Evict(typeof(Bar));
session.SessionFactory.E...
I am implementing a full text search using a view vw_SearchSite which has all the searchable fields and returning sites which have site IDs in common with the search results.
the query:
.....
<return alias="site" class="Site"/>
SELECT DISTINCT {site.*}
FROM v_Site {site}
WHERE {site}.Id IN (
SELECT Id
FROM vw_SearchSite
...
Hello,
I am using NHibernate for an ecommerce site and am having difficulty getting what should be a simple mapping to work. Essentially I have a ContactDetails entity which is used to save contact details for any type of user - Buyer/Seller/Advertiser/etc. I use an "any" mapping to allow a single table to hold contact_details for each t...
I am new to NHibernate.
I am using following property elements in my hbm file...
<property name="CountryId" length="4" />
<property name="CountryForCustomer"
formula="(SELECT *
FROM SystemCountry
WHERE SystemCountry.CountryId = CountryId)" />
Here I am trying to g...
In my APS.NET MVC project Im using DataAnnotations for validations.
I moved from L2S to NHibernate orm and in fact found that NHibernate has own validator (NHibernate.Validator)
Is it make sense to move to NHibernate.Validator as well?
for example DataAnnotations has [Required] attribute and NHibernate.Validator [NotEmpty, NotNull, No...
Hi guys,
I am using Wcf in Sharp Architecture. I have configured my project following northwind sample using WcfSessionStorage etc. I have a method in the wcf service that gets a list of business object using Repository<>.GetAll(). I am testing the service method using WcfTestClient. When the method is called the very first time, every...
Hi All:
I am new to this group so apologies if this has already been answered
(I have had a good look). I am having a look at sharp architecture for
a project I'm soon to start out on.
I am experimenting with the Northwind sample, and wanted to test a
self referential relationship, but discovered Fluent NHibernate 1.1
was needed (see
h...
Hi,
I'm wondering how I can represent the following in the criteria API
return DataContext.Session.CreateQuery("
select
ss.PracticeArea
from Subsection as ss
where ss.Location = :Location
")
.SetEntity("Location", location)
.List<PracticeArea>();
The where clause is straight forward enough the bit I'm ...