fluent

Fluent NHibernate Architecture Question

I have a question that I may be over thinking at this point but here goes... I have 2 classes Users and Groups. Users and groups have a many to many relationship and I was thinking that the join table group_users I wanted to have an IsAuthorized property (because some groups are private -- users will need authorization). Would you rec...

Fluent NHibernate Many-to-Many

I am using Fluent NHibernate and having some issues getting a many to many relationship setup with one of my classes. It's probably a stupid mistake but I've been stuck for a little bit trying to get it working. Anyways, I have a couple classes that have Many-Many relationships. public class Person { public Person() { G...

Combine Fluent and XML mapping for NHibnernate

Hi, I just fell in love with NHibernate and the fluent interface. The latter enables very nice mappings with refactoring support (no more need for xml files). But nobody is perfect, so I am missing the many-to-any mapping in fluent. Does anybody know if it is already there? If so, a simple line of code would be nice. But to stick to t...

How to map Dictionary<enum1,enum2> with Fluent Nhibernate

I was mapping a relation using something like the following <map name="Foo" cascade="all-delete-orphan" lazy="false"> <key column="FooId"/> <index column="FooType" type="Domain.Enum.FooType, Domain"/> <element column ="FooStatus" type="Domain.Enum.FooStatus, Domain"/> </map> The class is like this namespace Domain { public...

Is there a fluent assertion API for MSTest?

I've recently been exposed to the fluent interface in nUnit and I love it; however, I am using msTest. Does anyone know if there is a fluent interface that is either testing framework agnostic or for msTest? Thanks, Josh ...

NHibernate: Best way to deal with intermediary table using Fluent NHibernate?

How would you map the following in Fluent NHibernate? See "18.3. Customer/Order/Product" http://www.hibernate.org/hib_docs/nhibernate/html/example-mappings.html ...

Fluent NHibernate one-one mapping through additional table

I have a table A that has a references to a table B through a third table C. C contains the primary key of A and B. For each A there is at most one record in C. When I try to create a mapping for A such that I am referencing B, I use the References function, but it does not allow me to specify that the mapping goes through another table ...

How to specify table name in Fluent NHibernate ClassMap class?

Hi I am newbie to NHibernate and trying to use Fluent for mapping. My entity class name is different from the database table name it has to be mapped to. I am using mapping class derived from ClassMap<>, but I can't specify the table name: the property TableName from ClassMap is read-only. Thanks for your help. ...

Castle Windsor Fluent API: Define dependency explicitly

Given the below configuration Container.Register(Component.For<A>().Named("foo")); Container.Register(Component.For<B>().Named("foobar")); Container.Register( AllTypes.Pick() .FromAssemblyNamed("MyAssembly") .If(t => t.Name.EndsWith("ABC")) .Configure(c => c.LifeSt...

Inheritance Mapping with Fluent NHibernate

Given the following scenario, I want map the type hierarchy to the database schema using Fluent NHibernate. I am using NHibernate 2.0 Type Hierarchy public abstract class Item { public virtual int ItemId { get; set; } public virtual string ItemType { get; set; } public virtual string FieldA { get; set; } } public abstra...

Fluent Nhibernate and pluggable inheritance

Is there any way to define/expand inheritence without changing base table mapping with fluent nhibernate? For example with Castle.ActiveRecord (based on nhibernate) you can define inheritance like this: [ActiveRecord("entity"), JoinedBase] public class Entity : ActiveRecordBase { [PrimaryKey] public int Id{get;set;} } [ActiveR...

Fluent NHibernate, working with interfaces

I just switched to Fluent NHibernate and I've encountered an issue and did not find any information about it. Here's the case : public class Field : DomainObject, IField { public Field() { } public virtual string Name { get; set; } public virtual string ContactPerson { get; set; } public virtual bool Private ...

What fluent interfaces have you made or seen in C# that were very valuable? What was so great about them?

"Fluent interfaces" is a fairly hot topic these days. C# 3.0 has some nice features (particularly extension methods) that help you make them. FYI, a fluent API means that each method call returns something useful, often the same object you called the method on, so you can keep chaining things. Martin Fowler discusses it with a Java exa...

Fluent interfaces / extension methods - Turning a flat list into a navigation tree

I currently have an extension Method which converts an IEnumerable of type Tab into a hierarchical collection of TabNodes. // If Tab has no parent its ParentId is -1 public class Tab { public int TabId { get; set; } public string TabName { get; set; } public int Level { get; set; } public int ParentId { get; set; } } publ...

Is there any library to represent SQL queries as objects in Java code?

I was wondering if there is any library that can be used to represent SQL queries as objects in Java. In the code I have plenty of static variables of type java.lang.String that are hand written SQL queries. I would be looking for library having a nice fluent API that allows me to represent the queries as objects rather than strings. E...

Castle Windsor Fluent API: Define Array with Single item as Dependency

Given this XML configuration (which works) <component type="X.Y.Z.ActivityService, X.Y.Z.Services" id="X.Y.Z.ActivityService" lifestyle="transient"> <parameters> <Listeners> <array> <item>${DefaultActivityListener}</item> </array> </Listeners> </parameters> </component> <component type="X.Y.Z.DefaultActi...

NHibernate Traversal Question - Creating a Fluent Interface

I'm stumped with NHibernate and my Domain Model right now. I'm imagining a nice API in my head but I'm having a really hard time making it a reality. Here's an example of what I'm trying to accomplish: Trip trip = new Trip("Austria2009"); foreach(User user in trip.People.Crew.IsApproved()) { reponse.write(user.Firstname); } // Or ...

Fluent NHibernate: Prevent class from being mapped

Hi, I am sure it is a piece of cake, but I can't find it using google. I need to EXCLUDE a single class from mapping. My current configuration is: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.Is(@"Data Source=PC\SQLEXPRESS;......"))) .Mappings(m => ...

Private property mapping with fluent nhibernate

Hi, I am getting exception mapping a private property.This is the situation: I have this in Entity.cs: privat int m_Inactive; and in EntityMap.cs I have : Map(x => Reveal.Property("m_Inactive")).ColumnName ("INACTIVE"); But I get this error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of a...

How to map this using Fluent NHibernate

Here is an example of my class: public class ClassX { private ClassY _y; public ClassY PropertyA { get { return _y ?? (_y = new ClassY(this); } } } public class ClassY { public virtual string PropertyB { get; set; } } My table looks like this: table ClassX { PropertyB varchar } So I need PropertyA to be cons...