I've got a hibernate query that returns a list of objects and I want to order by a title. This is a user maintained field and some of our customers like prefixing their titles with numbers, this isn't something I can control. The data is something like this:
- 1 first thing
- 2 second thing
- 5 fifth thing
- 10 tenth thing
- 20 twe...
I'm currently using an attribute based approach to nhibernate session management, which means that the session is open for the duration of the Action method, but is closed once control is passed to the View.
This seems like good practice to me, however I'm running in to problems with lazy loaded collections. (This is complicated by th...
What is fuentHibernate? Why is it used? What is the difference between Hibernate and Fluent Hibernate?
...
Hi have the following tables defined in my database:
Transactions:
- TransactionID (PK, Identity)
- TypeID (FK)
- Amount
TransactionTypes:
- TypeID (PK, Identity)
- Type
ProductTransactions:
- TransactionID (PK)
- Discount
There are 2 types of transactions (Events and Products). Products have an additional Discount field so an addi...
Hi, so here's the code with irrelevant bits left out:
public IEnumerable<T> GetByQuery(Expression<Func<T, bool>> filter
{
try
{
return Session.Linq<T>().Where(filter);
}
catch(Exception ex)
{
// custom exception handling here
}
finally
{
CloseSession();
}
return null;
}
...
I have the following classes and fluent mappings:
public class A {
public virtual int Id { get; private set; }
public virtual string MyString { get; set; }
public virtual IList<B> MyChildren { get; set; }
}
public class B {
public virtual int Id { get; private set; }
public virtual DateTime TheDate { get; set; ...
I hardly have any idea how to proceed when deleting.
My problem is that if a category is associated to an issue, and I try to delete it from project, I should not be able to do that.
How can I do that? Help please.
I have 3 tables, Issue, Project, Category
The relationships are as follows:
1. A project may have many issues, an issue ...
How do I query a class of a specific entity in NHibernate?
I basically want a projection that returns a System.Type of each row that matches criteria.
I have looked at http://stackoverflow.com/questions/2787498/get-subclass-type-from-projection-with-nhibernate however when I create Projections.Property("alias.class") or Projections.Pr...
Hi all,
Using NHibernate I'm trying to get obtain a list of B's where an IList property of B contains a specific instance of A.
The following code should hopefully explain the situation more clearly:
public void test()
{
A a1 = new A();
A a2 = new A();
B b1 = new B();
b1.As = new List<A> { a1 };
// ...database save...
When moving to MVC, and now IIS7, we started having issues in that our HTTP Module that opens and closes the ISession was called on every request (static files, etc.). I wanted to avoid doing a full rewrite of NH session management, so I implemented this code in my module, to filter out everything but requests going to the mvchandler:
v...
I have a program with a base class (Message) from which many other classes derivate (notably Article and Comment). I would like to create a criteria that will select all the Comments for which the RootMessage property is of type Article (I have some other type of potential RootMessages). But I can't seem to find how to add that kind of c...
What is the best way trying to get a text search function using nhibernate? I have read about NHibernate.Search, but cannot find the library anywhere.
I downloaded the latest NHibernate source code(2.1.2) and compiled it, but i still cannot find NHibernate.Search.
Does anyone have any suggestions? Or any other methods to do text search...
I'm facing the same issue others already posted on SO: On reading objects from the database, NHibernate would update all the objects because the value of one field is not proper in the DB.
(In detail: A newly added date column contains "1/1/0001" in all rows, so on mapping, NHibernate replaces the date and, on tx.Commit(), updates every...
Hi, I've got a basic tree structure that is stored in a single table. Let's say this is my model:
public class TreeNode {
public virtual Guid Id { get; private set; }
public virtual string Name { get; private set; }
public virtual IEnumerable<TreeNode> Contents { get; private set; }
}
and the table:
TREE_NODES
PK_NODE Guid
...
Given the following InsertItemTemplate (simplified) I'm not getting anything back in the event object's Values collection.
<InsertItemTemplate>
Item:
<asp:DropDownList ID="ItemInsertType"
DataTextField="SearchItemName"
DataValueField="SearchItemID" runat="server" />
...
I am trying use NHibenate, Burrow and Ninject.
I cannot seem to be able to bind the Burrow ISession using ninject.
I currently have
Bind<ISession>().ToProvider( new BurrowFramework().GetSession()).InRequestScope();
I get the errors
"
cannot convert from 'NHibernate.ISession' to 'System.Type'
The best overloaded method match f...
I have the following model:
public class SomeObject1 {
public virtual Guid Id {get; set; }
public string Property1 {get; set; }
}
public class SomeObject2 {
public virtual Guid Id {get; set; }
public string Property2 {get; set;}
}
and the table
SOME_OBJECTS
PK_SOME_OBJECTS Guid
WHICH_OBJECT Integer
PROPERTY1 varchar2
...
Hello hope someone can help me on this.
I have a situation where I have:
User entity which stores all my users including admins.
Comments entity which stores all comment against users.
my problem is I'm also storing within the comment entity the user id of the admin who made the comment. So now I have the Comment entity having 2 userId...
Hello,
I've read various things but I didn't see something specific, so I'm reposting. Sorry if I missed one and duplicate posted.
I am storing files in a database; previously, with ADO.NET Entity Framework, I would use image type and it streams it as byte[] array.
Is that the approach to do it in NHibernate with FluentNHibernate map...
My query in HQL is basically:
select functionA(a, :paramA), functionB(b, :paramB), functionC(c, :paramC), sum(d)
from tableA
groupby by functionA(a, :paramA), functionB(b, :paramB), functionC(c, :paramC)
However this gets turned into SQL of
select functionA(a, @param0), functionB(b, @param1), functionC(c, @param2), sum(d)
from table...