public class ConfOrmInitializer {
private Mapper mapper;
private ObjectRelationalMapper orm;
private bool isInitialized;
private readonly Type[] tablePerClassEntities = new[] {typeof (Order), typeof (OrderItem)};
public IEnumerable<hbmmapping> GetCompiledMappingsPerClass() {
Initialize();
return mapper.CompileMappingForEach(tablePerClassEntities);
}
private void Initialize() {
if(isInitialized) { return; } isInitialized = true;
orm = new ObjectRelationalMapper(); mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));
// The real mapping orm.TablePerClass(tablePerClassEntities);
}
}
Show me on console the result of the mapping
it write out the hbm.xml mapping
var mapping = mapper.CompileMappingFor(typeof(Movement).Assembly.GetTypes().Where(t => t.Namespace == typeof(Movement).Namespace));
Console.Write(mapping.AsString());
Get the mapping of the only one entity (and it's relations..)
var orm = new ObjectRelationalMapper();
// The follow line show how compose patterns-appliers-packs and patterns-appliers
IPatternsAppliersHolder patternsAppliers =
//packs..
// Instancing the Mapper using the result of Merge
var mapper = new Mapper(orm, patternsAppliers);
// Note: I'm declaring the strategy only for the base entity
orm.TablePerClass
();
Click on a option package in left menù for details
Click on a option package in left menù for example
Cool Naming:
xxxx
Just Another Pack
yyyy
Test your package with your domain:
Please wait - we implement this function soon ;)
Have stuffs not conformed? No problem! See specifications & customizations
orm.Exclude(typeof(Movement<>)); - exclude from mapping a class (usefull
when u pass an assembly to ORM to Map all the entities contained..)
mapper.NotNullable(myEntity=> myEntity.Name); - force to
set NON nullable the 'Name' member for the myentity class. note that 'NotNullable'
is an extention method that u find in example folder in the source of ConfORM.
orm.VersionProperty(v => v.Version); - Setting the
version property using the base class. It is usefull when u have a base-class for
each entity and all entity have a Version property of name ...'Version'
mapper.Customize(map => map.Property(pq => pq.Group, pm
=> { pm.Length(50); pm.Column("GroupName"); })); - you can customize the
lenght and the name of a specific property. In this case the 'Group' property will
be a database field of 50 lenght and named 'GroupName'.
ConfORM is a new method to map a domain for Nhiberante ORM.
It's properly a fresh idea because all other method's (attribute, hbm, fluent) are
based on the idea of 'set-up' each property of the domain to instruct Nhibernate
HOW can access and menage data.
ConfORM instead start with convention to map the 'big' (the Conformed code) and
AFTER 'set-up' the 'not' conformed.
So u can have the full-focus on the part of the Domain that is 'important': all
that things that not fit the common behaviour and have a different logic.
About this project and authors
"Shopping on ConfORM" is a project started in agoust 2010 from an idea by Giovanni
Bismondo on the project of ConfORM by Fabio Maulo.