Skip to content

Instantly share code, notes, and snippets.

var orm = new ObjectRelationalMapper();
MapDomain(orm);
var mapper = new Mapper(orm);
RegisterPatterns(mapper);
CustomizeMapper(mapper);
var nhconf = ConfigureSessionFactory();
nhconf.AddDeserializedMapping(mapper.CompileMappingFor(GetDomainClasses()), "FullDomain");
var orm = new ObjectRelationalMapper();
var mapper = new Mapper(orm);
var entities = new List<Type>();
entities.AddRange(RunModuleMapping<GeneralsPatternsModuleMappings>(orm, mapper));
entities.AddRange(RunModuleMapping<MembershipModuleMapping>(orm, mapper));
entities.AddRange(RunModuleMapping<CrmModuleMapping>(orm, mapper));
# Ignore file for Visual Studio 2010
# use glob syntax
syntax: glob
# Ignore Visual Studio 2010 files
*.obj
*.exe
*.pdb
*.user
@fabiomaulo
fabiomaulo / gist:396085
Created May 10, 2010 14:19
under MS-PL
public void Persist(TDataRow dataRow)
{
var entity = Get(dataRow.PartitionKey, dataRow.RowKey);
if (entity != null)
{
var eTag = tableContext.GetEntityDescriptor(entity).ETag;
tableContext.Detach(entity);
tableContext.AttachTo(entityTableName, dataRow, eTag);
tableContext.UpdateObject(dataRow);
}
@fabiomaulo
fabiomaulo / gist:396117
Created May 10, 2010 14:46
Workaround for TableStorage DateTime precision (under MS-PL)
public static class DateTimeExtensions
{
public static DateTime RoundMilliseconds(this DateTime source)
{
return source.AddTicks(-(source.Ticks % (TimeSpan.TicksPerMillisecond * 10L)));
}
}
// On the fly ResultTransformer
public IDictionary<string, int> GetTagsCloud(Country country)
{
return Session.GetNamedQuery("TagsCloud").SetInt32("pCountry", country.Id)
.List<IList<object>>().ToDictionary(row => (string)row[0], row => (int) row[1]);
}
// config
<property name="current_session_context_class">
uNhAddIns.SessionEasier.Contexts.ThreadLocalSessionContext, uNhAddIns
</property>
// class impl
public class PersistenceRequest: IDisposable
{
private bool disposed;
private readonly ISessionFactory factory;
namespace NHibernate.Test.NHSpecificTest.NH2230
{
[TestFixture]
public class Fixture : BugTestCase
{
[Test]
public void CanCreacteRetrieveDeleteComponentsWithPrivateReferenceSetterToParent()
{
var entity = new MyEntity();
var component = new MyComponentWithParent(entity){Something = "A"};
public void DomainDefinition(ObjectRelationalMapper orm)
{
orm.TablePerClass(tablePerClassRootEntities);
orm.TablePerClassHierarchy(tablePerClassHierarchy);
orm.Exclude<HasActivities>();
orm.Exclude<HasActivitiesStructures>();
orm.Exclude<HasStructures>();
orm.Exclude<DailySold>();
orm.Exclude<HourlySold>();
public class CreatePhisicalMappings
{
[Test, Explicit]
public void CreateXmlMappings()
{
HbmMapping[] mappings = new ConfOrmInitializer().GetCompiledMappingsPerClass();
WriteAllXmlMapping(mappings);
}
private static void WriteAllXmlMapping(IEnumerable<HbmMapping> mappings)