I need to dynamically add named queries to the NHibernate configuration object. The search engines return few hits referencing NamedSQLQueryDefinition or NamedQueryDefinition. Below is what I'm attempting to do. I don't know what to provide to the NamedSQLQueryDefinition constructor to successfully create a query. Can anyone provide a sa...
HI All
I have two entity with in a many-to-many relation.
public class SecurityGroupMappingOverride : IAutoMappingOverride<SecurityGroup>
{
public void Override(AutoMapping<SecurityGroup> mapping)
{
mapping.HasManyToMany(x => x.Actions).ParentKeyColumn("securityGroupId").ChildKeyColumn("actionId").
LazyLoa...
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...
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; ...
Title: multiple class with same variable name list has issues in table definition (all indices not null)
lets say i have two class implementing from one interface
public interface IInterface1
{
IList<string> myList {get; set;}
}
public class class1 : IInterface1
{
IList <string> myList {get; set;}
public class1()
{
...
I have several entities configured via FNH to eager load child entities using the FetchMode.Eager syntax when I request instances (from the database). Now I was under the impression this would ignore any lazy loading in the mapping and populate the child entities with the 'real' data.
The reason why I want to do this is because I want t...
I have a class on which I'd like to define a unique key using Fluent NHibernate. I think I've done this correctly, but my unit tes,t in which I save two objects with the same value for the field in question, saves both items without error. Here's what I've got:
Mapping override:
public class ItemOverride : IAutoMappingOverride<Item>
...
I am trying to create a Unique Key on a class that includes the foreign key to its parent. However, I get the following error: "Could not determine type for Parent". Below is the class and Fluent NHibernate mapping. I get that it is unable to figure out an SQL type for the Parent class, since it is just a proxy for the ParentFk field...
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...
Today I upgraded my project to FluentNHibernate 1.1. Ever since, when running my project I get the following exception:
Could not find a setter for property 'FullName' in class 'MyNamespace.Employee'
The code for the FullName property is as follows:
public virtual string FullName
{
get
{
return FirstName + " " + La...
Hi,
I'm having a problem mapping the following classes
public class Cat
{
public virtual int id { get; set; }
public virtual string name { get; set; }
}
public class House
{
public virtual int id { get; set; }
public virtual string name { get; set; }
public virtual IList Cats{ get; set; }
}
And my DB tables look li...
I am using the above combo in a new web app Im doing just to try to learn to build new stuff to expand my knowledge. Im hoping to go live if I do a good job.. Im kind of new at MVC and the other products so I was trying to find a link to a good tutorial that set all of these up together. If anyone knows of one or maybe 2 that set up 3 of...
I have the following code in my repository. I use it for a product details page.
public Product GetBySlug(string slug)
{
return session.CreateCriteria(typeof(Product))
.SetFetchMode("CrossSell", FetchMode.Eager)
.Add(Expression.Eq("Slug", slug))
.UniqueResult<Product>();
}
This query currently gets one prod...
Hi all
I have a object model a bit like this:
public class Foo
{
public int Id {get;set;}
public string FooName {get;set;}
}
public class Bar
{
public int Id {get;set;}
public Foo Foo {get;set;}
}
These correspond to tables in the database in the typical one-to-many kind of way.
Using Linq to NHibernate to query Bars accord...
Hi, i have the following tables in my database:
Announcements:
- AnnouncementID (PK)
- Title
AnouncementsRead (composite PK on AnnouncementID and UserID):
- AnnouncementID (PK)
- UserID (PK)
- DateRead
Users:
- UserID (PK)
- UserName
Note: Usually i'd map the AnnouncementsRead using a Many to Many relationship but this table also ha...
I am trying to get a single property from a joined table where a non-PK in my main table is joined to the PK of the foreign table. Below is an oversimplified example of what I am trying to accomplish (I do not want to reference the foreign entity):
Tables:
CREATE TABLE Status
(
Id int,
Body text,
CategoryId int
)
CREATE TABLE C...
I have classes like
public class Content
{
// ...
public virtual IList<Detail> { get; set; }
}
public class Detail
{
// ...
public virtual Content Content { get; set; }
public virtual string Name { get; set; }
}
public class TagDetail : Detail
{
public virtual Tag Value { get; set; }
}
public class TagCollectionD...
Is anybody knows how doesnt schemaupdate work with many-to-many
e.g.:
i have category and product entities with many-to-many on each one:
how can i know when schemaupdate creates table: categoriesToProducts and when productsToCategories
ps. i dont want to specify tableName in my mapping
...
I have a model such as this (simplified)
public class Post
{
public string ID { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public string AuthorName { get; set; }
public List<string> Attachments { get; set; }
}
In my database, I have a Post table, and a PostAttachment table
...
I have an Abstract class:
[Serializable]
public abstract class BaseModel
{
public virtual int Id { get; private set; }
public virtual DateTime? CreatedOn { get; set; }
public virtual string CreatedBy { get; set; }
public virtual DateTime? UpdatedOn { get; set; }
public virtual string UpdatedBy { get; set; }
publi...