I am working with a legacy database that has a table to store up to 5 categories a user has permissions to view:
USER_ELIGIBILITY
----------------
Eligibility_Id INT PRIMARY KEY
Eligibility_Name NVARCHAR(100)
CategoryId1 INT
CategoryId2 INT
CategoryId3 INT
CategoryId4 INT
CategoryId5 INT
The following is how I have created the class:
...
Hi,
I know there are many threads about this around, but I've been trying everything I could see for a while now but still no luck.
I have an Item object, which contains a collection of itemdocument. Using nhibernate to link to the database, I can easily add to my collection of itemdocument, update items in it, etc, but whatever I do, ...
Hi all,
I'm using NHibernate with Fluent, and I'm trying to do a GetAll type thing using Critera.List:
public static List<T> GetAll(int pageIndex, int pageSize)
{
using (ISession session = Utils.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
...
Anyone have any idea why NHibernate would do this? Seems rediculuous to me and it's (obviously) crashing my app as it's trying to update primary key column. Here's what it's doing.
First, it inserts a record:
INSERT INTO WidgetConfigurationPositions
(WidgetId,
TargetId)
VALUES (256 /* @p0 */,
'row...
I'm having problems with getting nhibernate to play nice with sqlite:
My NHibernate configuration:
<NHibernate>
<hibernate xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.provider">NHibernate.Con...
I am trying to map the collection for two days without success. I also read all possible articles and forums but still down there. Ok, here is the problem:
1) The collection class contains a private field "_internalCollection" which is mapped with NHib.
2) The holding entity should expose the collection trough readonly property.
3) I ...
Hi all,
I have a class called User. User can have one or more roles, defined in an bitmask enum. The user has a Role property that i can use via:
user.Roles = Roles.User | Roles.Other;
In the database I have a Users table and a User_Roles table. For every role that a user has, i want to store it in the Users_Roles table with the Use...
Hi,
I have a table T1 that has these columns:
ID (int) - is a primary Key
Ref (int) - (not null)
Name (string)
And a second table T2 with columns:
T2ID (int) - is a primary key
Value1 (int)
Value2 (int)
SomeOtherData (int)
Each record from T1 has >2 records in T2: Ref column in T1 has a value from T2 table, T2ID column.
How to ...
Hi,
I'm trying to add a column to an existing table. I added a property to the mapping :
<property name="SelectionId" column="selection_id" not-null="true"/>
When I open the session, the new column is created, however the not-null attribute is not taken into account : the new column is nullable.
I realize you need to specify a defau...
Hi, these are the rules for the game:
0) You have to use NHibernate;
1) You have a working database with data which must stay "alive" after the update;
2) If you have 3 versions of the database schema (1.0, 2.0 and 3.0) you should be able to update low->high version. (high->low is optional);
I know about the methods schema.Create()/U...
Hi,
I get this:
"A storage mechanism has already been configured for this application"
The thing is - I already have another s#arp archtecture web app successfuly running on the server - could this be the problem?
I have this:
private void InitializeNHibernateSession()
{
NHibernateSession.Init(
we...
Hey,
I have a page where I show businesses that are within a certain number of miles of a user. I store the user and business's latitude and longitude in the database. Currently, I'm using NHibernate to return all businesses in the database, then checking each business to see if it's lat/long is within X miles of the user, then creating...
Hey there,
I'm working on an ERP application where multiple inventories need to be dynamically supported, ie. each depot/branch needs a separate stock value for each product. One approach - avoiding using static table columns - is to have a separate Stock table as follows:
[Product]
Code
...
[Branch]
Code
...
[Stock]
ProductCode
Bran...
Hey,
I'm trying to get businesses within a certain number of miles of a user, using a formula to get the distance between the lat/long of the business and the lat/long of the user. Here is the code:
var criteria = DetachedCriteria.For<Core.Models.Business>(); criteria.Add(Restrictions.Le(String.Format(@"(3959*acos(cos(radians({0})...
In Linq to NHibernate I'm trying to return businesses within a certain distance of a user. Here is what I have so far:
var query = from b in ActiveRecordLinq.AsQueryable<Business>()
where (3959 * Math.Acos(Math.Cos((Math.PI * coordinates.Latitude / 180)) * Math.Cos((Math.PI * b.Latitude / 180))
...
I have the following mapping:
<!-- WidgetConfiguration -->
<class name="MyProject.WidgetConfiguration, MyProject" table="WidgetConfigurations">
<id name="Id" column="Id" type="Int64">
<generator class="native" />
</id>
<property name="Name" column="ConfigurationName" />
<map name="Widgets" table="WidgetConfigurationPositio...
Database Strucutre:
Shows
ID
Name
Genres
ID
Name
ShowsGenres
ShowsID
GenresID
Above is my Database I am trying to figure out how to map this properly. My Show object is like this:
public class Show
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual IList<Genre> Genres { get; se...
Hi all. I hope you can help somewhat novice to NHibernate with the following question.
Suppose we have two table: Page and WorkPage. Page table contains unversioned data and WorkPage contains versioned Data of the same Page, i.e. there is a relation one-to-many between Page and WorkPage.
In the code we have an entity containing all of t...
I have been landed into the middle of a project that is using MVC2 & NHibernate. I haven't worked with NHibernate before, so as simple as this question might seem, I'm a bit out of my depth.
I have to create a directory for a number of Company Groups. The first task is to get a distinct list of the first letter for each company.
So if...
I have a method similar to the following, which I need to return all Groups that begin with the letter I'm passing in:
public IList<CompanyGroupInfo> GetGroupByQuery(string letter)
{
IList<CompanyGroupInfo> result = null;
result = _session
.CreateCriteria<CompanyGroupInfo>()
.Add(SqlExpression.Like<CompanyGroupI...