I'm trying to map a view without an identifier, but nhibernate still generates a sql with the id column (giving me a sql error, since the ID column does not exists in the db). Maybe I'm misunderstanding the Id() constructor?
constructor comments:
Create an Id that doesn't have a corresponding property in the domain object,
or a column ...
I would like to set up table-per-classhierarchy inheritance in nhibernate thru code. Everything else is set in XML mapping files except the subclasses. If i up the subclasses in xml all is well, but not from code. This is the code i use - my concrete subclass never gets created:(
//the call
NHibernate.Cfg.Configuration config = new NHi...
I have a SQL Query which works in SQL Management Studio:
Select Id
From table t
Where t.Date=
(Select Max(Date)
From (
Select *
From table where ReferenceId = xy) u)
Reason is, from all entries with a certain foreign key, I want to receive the one with
the highest date.
I tried to reform this Query for use in NHiber...
i use a nhibernate with ria services and i test my Domain classes in server and it works but when i want to use ria service in silverlight when i want to get a entityset like thise it give me that entityset is empty:
mainpage.xaml.cs:
public MainPage()
{
InitializeComponent();
AppointmentDomainContext context ...
I have a simple Parent/Child relationship between a Person object and an Address object. The Person object exists in the DB. After doing a Get on the Person, I add a new Address object to the Address sub-object list of the parent, and do some other updates to the Person object. Finally, I do an Update on the Person object. With a SQL...
So I only want the count of the results not the results themselves therefore I am using count in hql. So, below is the query
(int) Session.CreateQuery("select count(*) from TableName where Lhs=Rhs").UniqueResult();
But it is giving me the error Specified cast is not valid..
So, can any body tell me how to cast the count to int.
An...
Hello everyone,
i'm working on a small project that is supposed to allow basic searches of the database.
Currently i'm using nhibernate for the database interaction.
In the database i have 2 tables: Person and Address. The Person table has a many-to-one relationship with Address.
The code i've come up with for doing searches is:
publi...
I'm new to NHibernate, so this is probably my mistake, but when I use:
schema.Create(true, true);
I get:
SchemaExport [(null)]- There is already an object named 'XXX' in the database.
System.Data.SqlClient.SqlException: There is already an object
named 'XXX' in the database.
I grabbed the SQL code nHibernate was using, ran it dire...
How should I go about writing a backwards like statement using NHibernate criteria?
WHERE 'somestring' LIKE [Property] + '%'
Sub Question:
Can you access the abstract root alias in a SQLCriterion expression?
This is somewhat achievable using the SQLCriterion expression
Expression.Sql("? like {alias}.[Property] + '.%'", value, NHi...
I'm trying to restrict my NHibernate query with some basic date/time manipulation. More specifically, I want to execute the following statement (pseudo-SQL):
select * from article where created_on + lifespan >= sysdate
with:
created_on is mapped to a property of type DateTime.
lifespan is mapped to a property of type TimeSpan.
sysda...
Hi,
I have two objects with a many-to-many relationship between them, as follows:
public class LeftHandSide
{
public LeftHandSide()
{
Name = String.Empty;
Rights = new HashSet<RightHandSide>();
}
public int Id { get; set; }
public string Name { get; set; }
public ICollection<RightHandSide> Right...
Hi everybody. I'm using NHibernate with Lambda Extensions. I'd like to know how to nest a Max function with a Substring.
The following statement retrieves Max("invoice_id")
var ret = session
.CreateCriteria<Invoice>()
.SetProjection(Projections.Max("invoice_id"))
.UniqueResult();
but in my case the field...
Hi guys,
I wonder if Nihbernate close db connection supplied as a parameter to OpenSession method.
Example
using(var session = sessionFactory.OpenSession(connection))
{
}
I want connection to be disposed with the session.
Best regards,
Alexey Zakharov
...
Does nhibernate proxies do any smart job to make change tracking efficient? Or does it only support what Entity Framework calls snapshot based change tracking?
...
I have two classes: Cat and DomesticCat, that extends Cat.
I want to select all Cats, but no oneDomesticCat. How to do it using NHibernate criteria API?
...
Hi
I want assign connection string for NHibernate using following code and getting exception (bold).
log4net.Config.DOMConfigurator.Configure();
Configuration config = new Configuration();
IDictionary props = new Hashtable();
props["hibernate.connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
props["hibernate.d...
Hi guys,
How to set custom DriverConnectionProvider with Fluent NHibernate?
Best regards,
Alexey Zakharov
...
Hi everybody, I'm using Linq To Nhibernate, and with a HQL statement I can do something like this:
string hql = "from Entity e order by rand()";
Andi t will be ordered so random, and I'd link to know How can I do the same statement with Linq to Nhibernate ?
I try this:
var result = from e in Session.Linq<Entity>
orderb...
Hi,
When using Entity Framework with RIA domain services, domain services are inherited from LinqToEntitiesDomainService, which, I suppose, allows you to make LINQ queries on a low level (client-side) which propagate into ORM; meaning that all queries are performed on the database and only relevant results are retrieved to the server an...
We're using FluentNHibernate and we have run into a problem where our object model requires data from two tables like so:
public class MyModel
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual int FooId { get; set; }
public virtual string FooName { get; set; }
}
Where there is a ...