Format:
Recent snippets matching tags of nhibernate
private static ISessionFactory CreateSessionFactory() { var cfg = new Configuration().Configure("nhibernate.config"); cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionStringName, System.Configuration.ConfigurationManager.ConnectionStrings[System.Environment.MachineName].ConnectionString)); return cfg.BuildSessionFactory(); }
183 Views
no comments
namespace Northwind { /// <summary> /// A base class for all entities that implements identity equality. /// </summary> /// <typeparam name="TId">The type of the ID.</typeparam> /// <typeparam name="T">The type of the derived class (required for equality)</typeparam> public abstract class EntityBase<TId, T> where T : EntityBase<TId, T> { private TId _id;
223 Views
no comments
// pseudo: if month(entered) greater than or equal to 7, return year(entered) // else return year(entered)-1 (for school year conversion) // returns distinct list of "school years" var criteria = Session.CreateCriteria<MyEntity>(); var convertToSchoolYearProjection = Projections.Conditional( Restrictions.Ge( Projections.SqlFunction("month", NHibernateUtil.Int32,
1273 Views
no comments
class AuthorsByNameQuery { internal DetachedCriteria Criteria; public AuthorsByNameQuery() { Criteria = DetachedCriteria.For<Author>(); } public IList<Author> List(ISession session)
144 Views
no comments
public IQueryable<T> Query(Expression<Func<T, bool>> predicate) { IQueryable<T> returnValue; using (ITransaction transaction = _session.BeginTransaction()) { try { returnValue = _session.Linq<T>().Where(predicate); transaction.Commit(); }
273 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Text; using NHibernate; namespace Lucilla.Framework.Core.Data { public static class QueryExtensions {
370 Views
no comments
class Program { private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database( OracleClientConfiguration .Oracle10 .ConnectionString(Properties.Settings.Default.TWTest) .ProxyFactoryFactory(typeof(NHibernate.ByteCode.LinFu.ProxyFactoryFactory)))
1138 Views
no comments
For<IUnitOfWork>()
.LifecycleIs(new UniquePerRequestLifecycle())
.Use(x => new UnitOfWork(x.GetInstance<ISessionFactory>(Keys.SessionFactoryName)));
767 Views
no comments
public List<PersonInOrganization> ExtractInvalidEmails() { EntityCollection<PersonInOrganization> list = GetAllItems(); //my first LINQ use! var invalids = from l in list where !string.IsNullOrEmpty(l.Email) && !IsValidEmail(l.Email) select l; return invalids.ToList<PersonInOrganization>(); }
306 Views
1 comments
public bool OnPreInsert(PreInsertEvent @event) { var entity = @event.Entity as ParentVersion; if (entity == null) { return false; } var currentMaxVersion = @event.Session.CreateCriteria<ParentVersion>("pv") .Add(Restrictions.Eq("pv.Parent.Id", entity.Parent.Id))
187 Views
no comments
public class ParentMap : ClassMap<Parent> { public ParentMap() { Table("parent_def"); Id(x => x.Id,"parent_id"); Map(x => x.UID, "parent_uid").CustomSqlType("varchar").Length(40); Map(x => x.DeletedAt ,"dte_deleted").Nullable(); Map(x => x.ModifiedAt, "dte_modified").Nullable(); Map(x => x.CreatedAt, "dte_created").Nullable();
234 Views
no comments
.Mappings(m => {
m.FluentMappings.AddFromAssemblyOf<SomeMap>();
m.AutoMappings.AddFromAssemblyOf<SomeOtherMap>();
});
337 Views
no comments
<many-to-one cascade="all" update="false" insert="true" class="Data" foreign-key="backup_id" name="Data"> <column name="backup_id" /> </many-to-one>
191 Views
no comments
string res = string.Empty; try { IQuery query = session.CreateQuery("select ao.CostCenterAccount from " + "AssetObservation as ao where ao.Asset.ID=:KEY " + "and ao.Date<:DATETIME order by Date asc"); query.SetInt64("KEY", asset.Id); query.SetDateTime("DATETIME", dateTime);
627 Views
1 comments
Configuration config = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(
c => c.FromConnectionStringWithKey("ConnectionString"))
.Cache(c =>
c.UseQueryCache()
.QueryCacheFactory<StandardQueryCacheFactory>()
.ProviderClass<HashtableCacheProvider>()
.UseMinimalPuts()
)
.UseReflectionOptimizer()
229 Views
no comments
new PersistenceSpecification<Component>(session, new ComponentEqualityComparer()) public class ComponentEqualityComparer : IEqualityComparer { #region IEqualityComparer Members public bool Equals(object x, object y) { if (x == null || y == null) {
194 Views
no comments
private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 .ConnectionString(c => c .FromConnectionStringWithKey("MyStore.Properties.Settings.StoreConnectionString")) ) .Mappings(m => m.FluentMappings .AddFromAssemblyOf<Program>())
223 Views
no comments
public class XmlType : IUserType { public new bool Equals(object x, object y) { if (x == null || y == null) return false; var xdoc_x = (XmlDocument)x; var xdoc_y = (XmlDocument)y; return xdoc_y.OuterXml == xdoc_x.OuterXml;
500 Views
no comments
public static class ExtensionMethods { public static Configure FluentSagaPersister(this Configure config) { ISessionFactory sessionFactory = FluentConfig.GetFluentSessionFactory(); config.Configurer.RegisterSingleton<ISessionFactory>(sessionFactory); config.Configurer.ConfigureComponent<FluentSagaPersister>(ComponentCallModelEnum.Singlecall); return config; }
280 Views
no comments
public class FluentSagaPersister : ISagaPersister { /// <summary> /// Injected session factory. /// </summary> public ISessionFactory SessionFactory { get; set; } #region ISagaPersister Members public void Save(ISagaEntity saga)
313 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
