I have and entity lets call it Entity, and a Child collection Children.
I have a screen where the user has the Entity information, and a list with the Children collection, but that collection can be get very big, so i was thinking about using paging: get the first 20 elements, and lazy load the next only if the user explicitly presses t...
I have an odd requirement that my clients have imposed on me. They have certain queries which they have spent a lot of time optimizing that work as follows:
A stored procedure builds up an "id-list" which basically represents the "Where" filter
The id-list is joined into your data tables
The id-list would look something like this
...
I have a windows service that receives a large amount of data that needs to be transformed and persisted to a database. To ensure that we do not lose data, I want to create a "Write cache" for the data that will continue regardless if the database is online. Once the database becomes available again, I would want it to flush the content ...
I'm using nhibernate validator in my current solution. Everythings is almost fine but...
My view model has a property of type Gender (see example below)
public virtual Gender Gender { get; set; }
public enum Gender
{
Female = 1, Male = 2
}
Now i like to have some validation to ensure that the gender property ist set. But n...
I have a simple one to many association in my model. The parent class has a collection of children. In the mapping files, the association is a one to many, eager-loaded, using fetchmode.join. This works fine, but how can I write a criteria query but NOT trigger the loading of the child collection? In other words, I want to query the pare...
Hi All
I am trying to map Users to each other. The senario is that users can have buddies, so it links to itself
I was thinking of this
public class User
{
public virtual Guid Id { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtua...
Hello Folks,
I am trying to map a table frp, a SQL Server 2005 DB to a class which contains an enum:
public class MyClass{
private YesNoOptional addressSetting;
public YesNoOptional AddressSetting{
{get; set;}
}
}
public enum YesNoOptional {
Yes,
No,
Optional
}
This will dictate that one of three values is inserte...
Dear ladies and sirs.
I have an object O with 2 fields - A and B. How can I fetch O from the database so that only the field A is fetched?
Of course, my real application has objects with many more fields, but two fields are enough to understand the principal.
I am using NHibernate 2.1.
Thanks.
EDIT:
I wish to clarify. I need to fet...
Suppose I have a class Customer that is mapped to the database and everything is a-ok.
Now suppose that I want to retrieve - in my application - the column name that NH knows Customer.FirstName maps to.
How would I do this?
...
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(c => c
.Database(Database)
.TrustedConnection()
...
I am new to Hibernate world. It may be a silly question, but I am not able to solve it. I am testing many to One relationship of tables and trying to insert record. I have a Department table and Employee table. Employee and Dept has many to One relationship here. I am using Fluent NHibernate to add records. All codes below. Pls help
- S...
I'm trying to use nhibernate's query by example to build dynamic queries. I'm stuck on how to code for an example object with multiple associations. Here's an example from NHibernate in Action. Its a 'User' object with a property 'Items'.
Example exampleUser =
Example.Create(u).IgnoreCase().EnableLike(MatchMode.Anywhere);
Example e...
I want to return an entire entity, along with some aggregate columns. In SQL I would use an inner select, something like this:
SELECT TOP 10 f.*, inner_query.[average xxx]
FROM (
SELECT f.Id, AVG(fb.xxx) AS [average xxx]
FROM foobar fb
INNER JOIN foo f ON f.FoobarId = fb.Id
) AS inner_query
INNER JOIN foo f ON f.I...
Hello, colleagues.
I've got a problem at saving my entity.
MApping:
?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Clients.Core"
namespace="Clients.Core.Domains">
<class name="Sales, Clients.Core" table='sales'>
<id name="Id" unsaved-value="0">
...
I am using NHibernate 2.0.1 and .NET
I am facing issues with Lazy loading an association
I have a BusinessObject class that has associations to other BusinessObject in it, and it can go deeper.
The following function is in the BusinessObject to read the values of a collection in the BusinessObject.
public virtual object GetFieldVa...
Hi,Guys,i have a question about Criteria method,one-to-many relation to the database,'one' is "account",'many' is "sites",when i use CreateCriteria(),something appears let me in trouble.
Like this:"SessionFactory.OpenSession().CreateCriteria(typeof(Account)).List().Count();"
before it's run,i think the sql should be "Select count(*) f...
This is a pretty simple question. When I do this:
session.CreateCriteria(typeof(Product)).List();
The resulting list will load as I access it? Let's say, from 100 to 100 elements for example? Or will it load all once?
In the case it's not "virtual" how can I make it so? What's the best pratice about it?
Thanks;
...
I'm writing a notification platform using C# and NHibernate. I'm having difficulties with my queries.
I have a Customer entity - which contains an AssessmentCompleted Property. A notification should be sent out 21 months after certification. So my query needs to include all customers where their AssessmentCompletedDate + 21months < curr...
How to convert the following hql to Criteria API
var criteria = this.Session.CreateQuery("select m, m.Attachments.size from AdvanceMessage m");
?
Thanks
...
let's say I have 2 tables
table1(a,b) and table2(c,a)
I need to do something like this, but with NHibernate criteria:
select a,b, (select count(*) from table2 t2 where t1.a = t2.a ) x from table1 t1
anybody knows how to do this ?
...