First time journey with (Fluent) NHibernate. What I am trying to do is to add conventions for the attributes in System.ComponentModel.DataAnnotations.
How would I add a Check Constraint for the attribute.MinimumLength? Here is my code so far:
Thanks!
using System.ComponentModel.DataAnnotations;
using FluentNHibernate.Conventions;
usin...
Using Fluent NHibernate with automapping, I am trying to map the following domain:
public class Company: IModel
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
public class Account: IModel
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual C...
I have a simple class that looks like this:
public class Item {
// some properties
public virtual IDictionary<string, Detail> Details { get; private set; }
}
and then I have a map that looks like this:
map.HasMany(x => x.Details).AsMap<string>("Name").AsIndexedCollection<string>("Name", c => c.GetIndexMapping()).Cascade.All().KeyCol...
I have to display some objects which are stored in a relational database and I use fluent NHibernate to get them.
Since I need paging, I have to get both - the count of all objects, and the objects for the current page themselves.
The ICriteria for both purposes is very similar up to a point - for count i finally add
.SetProjection(Pro...
How to change the column order in a multi-column index?
I.e:
mapping.References(x => x.SomeReference).SetAttribute("index", "IX_index");
mapping.Map(x => x.SomeField).SetAttribute("index", "IX_index");
Produces the following Schema:
create index IX_index on ApplicantProgramDatas (SomeField, SomeReferenceId)
But I want to get:
crea...
I have the following classes:
public class InventoryItem
{
private Usage[] usages = new Usage[12];
virtual public Usage[] Usages { get { return usages; }}
virtual public string Name{get;set;}
}
public class Usage
{
virtual public double Quantity{get;set;}
virtual public string SomethingElse{get;set;} ...
I'm using NHibernate with Burrow and Fluent to shuttle data from SQLServer2005 into a directory full of FoxPro 7 dbf's.
When I try to save a new record through Burrow's GenericDAO, I get an exception that boils down to "Field XXX does not accept null values," where field XXX is a NOT NULL field that is not being mapped at all because it...
I'm trying to figure out what the convention would be for a value object list, in this case an IList. Here a code fragment for my domain model:
public class RegionSetting : Entity {
public virtual bool Required { get; set; }
public virtual string Name { get; set; }
public virtual IList<string> Options { get; set; }
}
My au...
I'm having some trouble getting fluent nhibernate to properly map the class hierarchy that I have.
Presuming that I have the following class structure
public abstract class MedicationAction
{
... Id and other attributes
public virtual MedicationStatus MedStatus { get; protected set; }
}
public class CeaseAction : MedicationActio...
I have a scenario where I have a propertybag of key/values that would look something like:
Entry 1 : key="Load", value="2", type="int"
Entry 2 : key="DailyStatus", value="0", type="bool"
I am trying to figure out if it's possible with nhibernate to map these values to a single table that I can pull out at a later time into .net simple...
I have the following domain graph, representing an insurance claim which can be against a vehicle or property:
public enum InvolvedPartyContext
{
Vehicle = 1,
Property = 2
}
public class Claim
{
public virtual Guid Id { get; set; }
public virtual InvolvedPartyContext InvolvedPartyContext { get; set; }
public virtual...
Can I mix fluent mapping with automapping? If yes how can it be done?
...
I'm working with an existing database that uses some really ugly conventions. I'd like to use NHibernate, and I think I can fix all these ugly DB conventions using Fluent NHibernate's auto mapping conventions. I'd like to avoid writing all the entity classes by hand. (This is where LINQ to SQL and SubSonic are appealing)
Is it possib...
New to NHibernate. Having trouble wrapping my head around how to map this legacy table.
CREATE TABLE [dbo].[CmnAddress](
[addressId] [int] NOT NULL,
[objectType] [varchar](63) NULL,
[objectId] [int] NULL,
[addressType] [varchar](7) NULL,
[recordStatus] [char](1) NULL,
[fromDate] [int] NULL,
[toDate] [int] NULL,
[onStreet] [varchar](254...
I have the following seemingly simple scenario, however I'm still pretty new to NHibernate.
When trying to load the following model for an Edit action on my Controller:
Controller's Edit Action:
public ActionResult Edit(Guid id)
{
return View(_repository.GetById(id));
}
Repository:
public SomeModel GetById(Guid id)
{
using ...
If we consider this example
But now quantity is a Value Object instead of a primitive type:
public class LineItem
{
public Quantity Quantity { get; set; }
public Product Product { get; set; }
}
instead of:
public class LineItem
{
public int Quantity { get; set; }
public Product Product { get; set; }
}
how could i map...
Hi, I am new to all the OOP and ORM stuff, so i would appreciate your help...
I have a Team Class:
public class Team : IEntity<Team>
{
public virtual int ID { get; private set; }
public virtual string Code{ get; private set; }
public virtual TeamWorker TeamLeader { get; private set; }
public virtual IEnumerable<TeamW...
Is there a way that I filter out rows in a HasManyToMany mapping?
I have three tables (legacy, not able to change them) Service, Resource and ResourceService. The ResourceService allows multiple resources to link to multiple services but it also has an "Active" column.
On my Resource domain object I've mapped the services linked to the...
I have a base class, which has 2 derived class.
Each derived class has a mapping file (they base class has non and it's abstract)
Each derived class has an object that points to itself (which is defined in the base class);
class Base
{
Base myManager;
}
class Derived1 : Base
{
}
Class Derived2 : Base
{
}
for each derived class ...
First of all, I'm using Fluent NHibernate with LinqToNHibernate.
I've got a query to do a search on a table based on what data the user entered. So, for example, I'm doing something like this:
'build the initial query that we will filter--this is lazy loaded
Dim results As IEnumerable(Of Customers) = Me.GetCustomers()
...