Okay, I have a database, but no tables in it. I have some entity classes. I'm trying to setup Fluent NH to do automappings with automatic schema export.
First, this is possible, right?
Second, if so, what am I doing wrong here:
private ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
.D...
What are the differences in syntax and semantics between NHibernate mapping 2.0 and 2.2?
...
// Request.hbm.xml
<many-to-one name="Grant" class="Grant" column="GrantId" lazy="false"/>
// Grant.hbm.xml
<set name="requests" table="Request" generic="true">
<key column="GrantId" />
<one-to-many class="Request"/>
</set>
The mapping works for everything else that uses the Grant property of Request. (...
Given a class A related to another class B in a one-to-many relationship, how can you create an NHibernate query (using the Criteria API--no HQL) to find all objects A who "have none" of the related objects B? Specifics follow, but I wanted to get the question out there first.
I have two model classes, Sample and SampleDiagnosis. Sam...
Hi,
I want map my object model to NHibernate. There is one tricky part in my concept and I don't know if it is possible to do this in NHibernate.
I want to have a collection of trees. I have two classes (below, only important properties indicated). Component is a node of a tree and ComponentGroup is a collection of trees.
public class...
Hi
Anyone knows how to use Projections.Conditional to produce something like "case ... when..."
The following code gives a wrong query:
IProjection isError = Projections.Conditional( Expression.Eq( "event.LogLevel", eLogLevel.Fatal.ToString( ) ), Projections.Constant( 1 ), Projections.Constant( 0 ) );
ICriteria criteria = Session.Cre...
I have a recursive one-to-many relationship that has the default lazy value of true. What code can I write against the NH API that will efficiently retrieve the ENTIRE tree AS IF I had lazy="false" on the SubCategories mapping?
Here's the recursive one-to-many relationship:
<class name="Category" lazy="false">
...
<list name="S...
Hi,
I have been playing around with the AbstractSearchFilter featured in Ayende blog here. The idea is you abstract the query building for search to the UI. While I can see how it works for simplistic restriction queries I am struggling to see how this could be used for something such as subqueries on ID, which are very comment in my ap...
Working on a project where I have more or less carte blanche to modify the database schema and object model (nice position to be in. (c:) Suppose I have a trivial inheritance tree like:
class Parent
{
public int ID { get; set; }
}
class Child : Parent
{
// some fields
}
Is it better to have a database schema where the child ...
I have the a class similar to the following (nb! names have been changed to protect the innocent):
public class Person
{
public virtual int Id { get; private set; }
public virtual string Name { get; set; }
public virtual DateTime Birthday { get; set; }
public virtual TimeSpan Age { get { return DateTime.Now - this.Birth...
I am trying to do a like comparison based on an outside parameter (passed by a search form) that determines type of comparison ("%string" or "string%" or "%string%")
I was thinking in the following direction:
query = query.Where(
Entity.StringProperty.Like("SearchString", SelectedComparsionType)
)
Like method would than based on sel...
The following is some background info on this post. You can just skip to the question if you like:
In this excellent article (http://ayende.com/Blog/archive/2009/04/28/nhibernate-unit-testing.aspx) the author contends that "When using NHibernate we generally want to test only three things:
1) that properties are persisted,
2) that casca...
I would like to build a DLL (which should be accessed from a web service and possibly from another application through automation).
Is there any possibility using NHibernate inside this dll (so accessing the dll through automation would work) ?
I am already using NHibernate in a rich client application and it is very handy , but I hav...
I am following along with the Summer of NHibernate Screencast Series and am running into a strange NHibernate Exception.
NHibernate.Hql.Ast.ANTLR.QuerySyntaxException:
Exception of type
'Antlr.Runtime.NoViableAltException' was thrown.
[select from DataTransfer.Person p where p.FirstName=:fn].
I have deviated from the Screencast Series...
Hi,
Struggling between choosing linq2sql and nhibernate.
Let me give you some insight in the application in point form:
this is a asp.net mvc application
it will have lots of tables, maybe 50-60 (sql server 2008)
i would want all the basic crud logic done for me (which I think nhiberate + repository pattern can give me)
i don't have ...
Hey,
I have a web service that accepts an Invoice, which contains LineItem children. It then updates the database to either create or update the Invoice using NHibernate.
When an invoice is updated, it is passed to the web service along with all LineItem children it now has. Adds and updates work perfectly. However, if a child LineI...
I'm using the following code in an ASP.NET page to create a record, then count the records to make sure I haven't exceeded a set limit and rollback the transaction if I have.
using (var session = NhibernateHelper.OpenSession())
using (var transaction = session.BeginTransaction())
{
session.Lock(mall, LockMode.None);
var voucher...
Can someone tell me how to accomplish this mapping using Fluent NHibernate? It's simply an account table with a composite key, that has many child accounts in a conjunction table.
Here's the working NHibernate mapping and the create SQL it generates:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-impo...
I have a complex, 3NF database being provided to me for a particular project. I would like to avoid using a class-per-table domain design. Rather, I would like to model my domain objects after how they are used from a conceptual business perspective.
The rub is how to properly persist this information. I know I can go the ADO route, ...
I'm trying to do a like search against an integer column, what I need to do is actually cast the column to a varchar and then do the like search. Is this possible? what's the easiest way to do this using the Criteria API?
var search = "123";
criteria.Add(Restrictions.Like("Number", "%" + search + "%"))
...