I'm using NHibernate to load some objects into my ASP.NET MVC application.
For example, a submission is submitted by a user, and I want to display the username (but only the username) of a user, like this:
<%= Html.Encode(item.User.UserName) %>
When I load a submission using NHibernate, the User is lazy-loaded from the database, whic...
Hello.
Im trying to insert object into SQLite InMembory database as follow:
private void button1_Click(object sender, EventArgs e)
{
var sessionFactory = CreateSessionFactory();
using (var session = sessionFactory.OpenSession())
{
Person p = new Person { Age = 25, FirstName = "Dariusz", LastName =...
I have an object with a property that I'd like to map as Serializable. NHibernate supports this:
<property name="FeeGenerator" column="FeeGenerator" type="Serializable" />
Is there a way to accomplish this in Fluent NHibernate?
There's an SO question (http://stackoverflow.com/questions/2000798/map-to-serializable-in-fluent-nhiberna...
Hi,
I'm currently using nHibernate and having a problem where two objects loaded separately but representing the same entity in the database do not have equal references.
See the following section of code for example:
CrudRepository<Customer> cr1 = new CrudRepository<Customer>();
Customer c1 = cr1.GetById(new Guid("0D19B0F0-CA41-4D4B-...
Why can NHibernate create a proxy for classes with properties that have private setters but not for classes with properties that have internal setters? Or am I missing something that should be completely obvious?
public class PrivateSetter {
// no proxy error
public virtual string PrivateSetterProperty { get; private set; }
}
...
I can't get any logging of NHibernate or my application. I tried EVERYTHING that I could think about, but nothing work!
Here is my code:
using System.Reflection;
using NHibernate.Cfg;
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
namespace NHibernate_Log4Net
{
class Program
{
s...
I think that Entities should implement equality by primary key comparison as default, but the nhibernate documentation recommends using business identity:
The most obvious way is to implement Equals()/GetHashCode() by comparing the identifier value of both objects. If the value is the same, both must be the same database row, they a...
I don't want to write stored procedures any more (not unless I have to), so should I use out of the box Linq-to-SQL or the Castle ActiveRecord implementation?
I understand there are some differences between the two as mentioned here on Stackoverflow
...
Hi all,
I ve got an employee that holds several addresses in a collection.
public class Employee
{
public string Name { get; set; }
public AddressCollection Addresses { get; }
}
public class AddressCollection : IEnumerable<Address>
{
private readonly Employee employee;
private IList<Address> items = new List<Address>...
Hi, I've got a problem with mapping many-to-one in the following code:
...
<property name ="CustomerID"/>
<!-- Many-to-one mapping: Customer -->
<many-to-one name="Customer"
class="Customer"
column="CustomerID"
insert="false" update="false"/>
<property name="Dat...
Hi, I have a multithreaded NHibernate application with ThreadStaticSessionContext.
I bind un each thread a new session. Before exiting the thread I commit the transaction and i get
enumerator was modified
at NHibernate.Util.SequencedHashMap.OrderedEnumerator.MoveNext()
at NHibernate.Util.IdentityMap.get_EntryList()
at NHiber...
I have the following set of tables in an existing database.
Resource - ResourceID
LocalisedResource - LocalisedResourceID, ResourceID, Language, Culture, LocalisedTerm
Office - OfficeId, NameResourceId
Now I wan to query for a particular office and get back the office's name for a particular language culture combination falling back ...
Hi All
I am looking for the best way to delete all schema changes(all tables really) made when unit testing.
I am using fluent to map my entities and create the schema in the Setup of my tests. I want to be able to delete the schema changes at the end of the tests in the Teardown.
I am using nhibernates SchemaExport to generate the sc...
How to change command Timeout for a session in nHibernate. I know it can be done in App.Config but I want to increase the default value only for one business operation.
...
Hello,
I'm working on getting started with NHibernate on a large scale project (have worked with it in small-scale before), and am digging into the issue of managing relationships... specifically, what best practices are out there for doing so?
Example: The classic: you have a Blog and Comments, the blog points to (0-n) comments, each ...
If I have an Order class an as aggregate root and 1000 line items.
How do I load just one of the 1000 line items? As far as I understand, a line item can only be accessed through the Order class and has a "local" identity. Would I still create a repository method at the OrderRepository like "GetLineItemById"?
Edit to comment the answer...
I'm trying to insert around 16000 records into a single table. Because this is very slow, I'd like to batch insert them. However, I'm always getting a timeout error when I attempt to do this. So I have two questions:
What is the best way to speed up inserts?
How do I increase the timeout value of the connection?
...
Hello,
I have a class called LoanApplication, and it has a collection property set up called Workflow. In the mapping file, I am setting the order of retrieval of the Workflow records to sort by Date, so the current workflow is always the first item in the list.
Now I want to query by the current workflow to get LoanApplications that a...
I have a parent class that contains a list of children. I have the parent and child mapped bidirectional with a has-many and an inverse on the parent with cascade.all turned on. If I modify an object in the child list, but no property on the parent, nHibernate does not save the child. If I modify a property on the parent everything saves...
Hi all,
I have the following nhibernate cfg file:
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">Data Source=dbFile.db;Version=3</property>
<property name="di...