本文整理汇总了C#中ISessionFactory类的典型用法代码示例。如果您正苦于以下问题:C# ISessionFactory类的具体用法?C# ISessionFactory怎么用?C# ISessionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISessionFactory类属于命名空间,在下文中一共展示了ISessionFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IsDynamicComponentDictionaryGetter
public static bool IsDynamicComponentDictionaryGetter(MethodInfo method, Expression targetObject, IEnumerable<Expression> arguments, ISessionFactory sessionFactory, out string memberName)
{
memberName = null;
// A dynamic component must be an IDictionary with a string key.
if (method.Name != "get_Item" || !typeof(IDictionary).IsAssignableFrom(targetObject.Type))
return false;
var key = arguments.First() as ConstantExpression;
if (key == null || key.Type != typeof(string))
return false;
// The potential member name
memberName = (string)key.Value;
// Need the owning member (the dictionary).
var member = targetObject as MemberExpression;
if (member == null)
return false;
var metaData = sessionFactory.GetClassMetadata(member.Expression.Type);
if (metaData == null)
return false;
// IDictionary can be mapped as collection or component - is it mapped as a component?
var propertyType = metaData.GetPropertyType(member.Member.Name);
return (propertyType != null && propertyType.IsComponentType);
}
开发者ID:snbbgyth,项目名称:WorkFlowEngine,代码行数:29,代码来源:VisitorUtil.cs
示例2: VartotojaiController
public VartotojaiController(IAuthenticationProvider authenticationProvider, ISessionFactory sessionFactory, [LoggedIn] UserInformation loggedInUser, HashAlgorithm hashAlgorithm)
{
_authenticationProvider = authenticationProvider;
_sessionFactory = sessionFactory;
_loggedInUser = loggedInUser;
_hashAlgorithm = hashAlgorithm;
}
开发者ID:zaLTys,项目名称:osfi,代码行数:7,代码来源:VartotojaiController.cs
示例3: ActionTransactionHelper
public ActionTransactionHelper(
ISessionFactory sessionFactory,
ICurrentSessionContextAdapter currentSessionContextAdapter)
{
_sessionFactory = sessionFactory;
_currentSessionContextAdapter = currentSessionContextAdapter;
}
开发者ID:kanayabhattad,项目名称:EventKarma,代码行数:7,代码来源:ActionTransactionHelper.cs
示例4: UseNHibernate
public static void UseNHibernate(this AppConfigurator configurator, ISessionFactory sessionFactory)
{
var runtime = configurator.AppRuntime;
runtime.Container.Register<IDomainDbSession>(_ => new NhDomainDbSession(sessionFactory.OpenSession()));
runtime.Container.Register<IDomainRepository>(_ => new NhDomainRepository(_.Resolve<IDomainDbSession>(), _.Resolve<IRelayWorker>()));
}
开发者ID:mouhong,项目名称:Taro,代码行数:7,代码来源:NHibernateConfiguration.cs
示例5: Update
public static void Update(ISessionFactory sessionFactory)
{
var factory = (ISessionFactoryImplementor) sessionFactory;
var dialect = factory.Dialect;
var connectionHelper = new SuppliedConnectionProviderConnectionHelper(factory.ConnectionProvider);
factory.Dialect.Keywords.AddAll(GetReservedWords(dialect, connectionHelper));
}
开发者ID:jaundice,项目名称:nhibernate-core,代码行数:7,代码来源:SchemaMetadataUpdater.cs
示例6: GenerateData
private static void GenerateData(ISessionFactory factory, Type entityClass, IGeometryCreator creator)
{
using (ISession session = factory.OpenSession())
{
using (ITransaction tx = session.BeginTransaction())
{
try
{
for (int i = 0; i < GeneratedRowsPerEntityCount; i++)
{
IGeometry geom = creator.Create();
geom.SRID = 4326;
object entity = Activator.CreateInstance(entityClass, i, "feature " + i, geom);
session.Save(entity);
}
}
catch (Exception e)
{
throw new ApplicationException("Failed loading data of type "
+ entityClass.Name, e);
}
tx.Commit();
}
}
}
开发者ID:abrobston,项目名称:NHibernate.Spatial,代码行数:25,代码来源:DataGenerator.cs
示例7: GetSessionFactory
public static ISessionFactory GetSessionFactory()
{
if (_isf != null) return _isf;
var cfg = new StoreConfiguration();
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(
"Server=localhost; Database=Test; Trusted_Connection=true; MultipleActiveResultSets=true")
)
.Cache(c => c.ProviderClass(typeof(NHibernate.Caches.Redis.RedisProvider).AssemblyQualifiedName)
.UseQueryCache().UseSecondLevelCache())
.Mappings(m =>
m.AutoMappings
.Add(AutoMap.AssemblyOf<Person>(cfg)
.Conventions.Add<ReferenceConvention>()
.Conventions.Add<HasManyConvention>()
.Override<Country>(x => x.HasMany(y => y.NaturalBorns).KeyColumn("CountryBorned_CountryId"))
)
)
.BuildSessionFactory();
_isf = sessionFactory;
return _isf;
}
开发者ID:MichaelBuen,项目名称:Demo_NHibernate_Plus_Redis,代码行数:28,代码来源:NHMapping.cs
示例8: Setup
public void Setup() {
_databaseFileName = Path.GetTempFileName();
_sessionFactory = DataUtility.CreateSessionFactory(_databaseFileName);
_tempFolder = Path.GetTempFileName();
File.Delete(_tempFolder);
var appDataFolder = AppDataFolderTests.CreateAppDataFolder(_tempFolder);
var builder = new ContainerBuilder();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>();
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
builder.RegisterType<StubReportsCoordinator>().As<IReportsCoordinator>();
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>();
builder.RegisterType<SqlCeCommandInterpreter>().As<ICommandInterpreter>();
builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>();
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
builder.RegisterType<DefaultDatabaseCacheConfiguration>().As<IDatabaseCacheConfiguration>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
builder.RegisterInstance(new ShellBlueprint { Records = Enumerable.Empty<RecordBlueprint>() }).As<ShellBlueprint>();
builder.RegisterInstance(new ShellSettings { Name = "temp", DataProvider = "SqlCe", DataTablePrefix = "TEST" }).As<ShellSettings>();
builder.RegisterModule(new DataModule());
_container = builder.Build();
_interpreter = _container.Resolve<IDataMigrationInterpreter>() as DefaultDataMigrationInterpreter;
_schemaBuilder = new SchemaBuilder(_interpreter);
}
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:30,代码来源:SchemaBuilderTests.cs
示例9: DefaultSessionProvider
public DefaultSessionProvider(ISessionFactory sessionFactory)
{
if (sessionFactory == null)
throw new ArgumentNullException("sessionFactory");
this.sessionFactory = sessionFactory;
}
开发者ID:BrandyFx,项目名称:Brandy,代码行数:7,代码来源:DefaultSessionProvider.cs
示例10: UnitOfWork
public UnitOfWork(ISessionFactory sessionFactory)
{
_sessionFactory = sessionFactory;
Session = _sessionFactory.OpenSession();
Session.FlushMode = FlushMode.Auto;
_transaction = Session.BeginTransaction(IsolationLevel.ReadCommitted);
}
开发者ID:rasouza1982,项目名称:RepositoryPattern,代码行数:7,代码来源:UnitOfWork.cs
示例11: NHibernateEventStoreTransaction
public NHibernateEventStoreTransaction(ISessionFactory sf)
{
this.SessionFactory = sf;
this.Session = sf.OpenSession();
WebSessionContext.Bind(this.Session);;
}
开发者ID:ikhwanhayat,项目名称:Vaccine-CQRS,代码行数:7,代码来源:NHibernateEventStoreTransaction.cs
示例12: Init
private static void Init()
{
nhConfiguration = new Configuration();
//nhConfiguration.Configure("NhibernateUtils/NHibernate.cfg.xml");
nhConfiguration.AddAssembly("Activos");
sessionFactory = nhConfiguration.BuildSessionFactory();
}
开发者ID:kelvin088,项目名称:Activos,代码行数:7,代码来源:NHConnection.cs
示例13: DestroySagaPersisterContext
public void DestroySagaPersisterContext()
{
SagaPersister = null;
SessionFactory.Dispose();
SessionFactory = null;
DeleteFile();
}
开发者ID:jhicks,项目名称:NServiceBus.Db4o,代码行数:7,代码来源:Db4oSagaPersisterTestFixture.cs
示例14: Open
public ISession Open()
{
if(_sessionFactory == null)
_sessionFactory = configureSessionFactory();
return _sessionFactory.OpenSession();
}
开发者ID:joeyshipley,项目名称:TestingPractices,代码行数:7,代码来源:SessionProvider.cs
示例15: ExampleFactoryManager
public ExampleFactoryManager(string configSectionName = "ExampleDatabaseConnectionSettings")
{
var configuration = Fluently.Configure();
configuration.InitializeFromConfigMsSql(configSectionName);
configuration.AddMappingsFromAssemblyOf<UserMap>();
_instance = configuration.BuildSessionFactory();
}
开发者ID:fr4gles,项目名称:Simplify,代码行数:7,代码来源:ExampleFactoryManager.cs
示例16: TestClassSetup
public static void TestClassSetup(TestContext context)
{
_configuration = new Configuration();
_configuration.Configure();
_configuration.AddAssembly(typeof(Draft).Assembly);
_sessionFactory = _configuration.BuildSessionFactory();
}
开发者ID:Snidd,项目名称:RotisserieDraft,代码行数:7,代码来源:TestMemberRepository.cs
示例17: Setup
public void Setup()
{
Configure.ConfigurationSource = new DefaultConfigurationSource();
NHibernateSettingRetriever.AppSettings = () => new NameValueCollection
{
{"NServiceBus/Persistence/NHibernate/dialect", dialect}
};
NHibernateSettingRetriever.ConnectionStrings = () => new ConnectionStringSettingsCollection
{
new ConnectionStringSettings("NServiceBus/Persistence/NHibernate/Timeout", connectionString)
};
ConfigureNHibernate.Init();
Configure.With(Enumerable.Empty<Type>())
.DefineEndpointName("Foo")
.DefaultBuilder()
.UseNHibernateTimeoutPersister();
persister = Configure.Instance.Builder.Build<TimeoutStorage>();
sessionFactory = persister.SessionFactory;
new Installer.Installer().Install(WindowsIdentity.GetCurrent().Name);
}
开发者ID:ranji,项目名称:NServiceBus,代码行数:26,代码来源:InMemoryDBFixture.cs
示例18: CreateSessionFactory
private static void CreateSessionFactory()
{
// FluentNHibernate.Search Configuration
Configuration fnhscfg = FluentSearch.Configure()
.DefaultAnalyzer().Standard()
.DirectoryProvider().RAMDirectory()
.IndexingStrategy().Event()
.Listeners(ListenerConfiguration.Default)
.MappingClass<SearchMap>()
.BuildConfiguration();
// FluentNHibernate Configuration
Configuration fnhcfg = Fluently.Configure(fnhscfg)
.Database(SQLiteConfiguration.Standard.InMemory()
.Dialect<SQLiteDialect>()
.ConnectionString(ConnectionString)
.ProxyFactoryFactory<ProxyFactoryFactory>())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AuthorMap>())
.ExposeConfiguration(cfg =>
{
cfg.SetListeners(ListenerType.PostInsert, new[] { new FullTextIndexEventListener() });
cfg.SetListeners(ListenerType.PostUpdate, new[] { new FullTextIndexEventListener() });
cfg.SetListeners(ListenerType.PostDelete, new[] { new FullTextIndexEventListener() });
cfg.SetListener(ListenerType.PostCollectionRecreate, new FullTextIndexCollectionEventListener());
cfg.SetListener(ListenerType.PostCollectionRemove, new FullTextIndexCollectionEventListener());
cfg.SetListener(ListenerType.PostCollectionUpdate, new FullTextIndexCollectionEventListener());
})
.BuildConfiguration();
_cfg = fnhcfg;
_sessionFactory = _cfg.BuildSessionFactory();
}
开发者ID:jaredmahan,项目名称:Fluent-NHibernate-Search,代码行数:33,代码来源:SessionFactory.cs
示例19: Initialize
/// <summary>
/// Called by the framework to initialize the persistent store.
/// </summary>
public void Initialize()
{
Platform.Log(LogLevel.Info, "Initializing NHibernate subsystem...");
// create the hibernate configuration
_cfg = new Configuration();
// this will automatically read from the app.config
_cfg.Configure();
Platform.Log(LogLevel.Debug, "NHibernate connection string: {0}", this.ConnectionString);
// add each assembly to the hibernate configuration
// this tells NHibernate to look for .hbm.xml embedded resources in these assemblies
// TODO: we should only scan plugins that are tied to this PersistentStore, but there is currently no way to know this
var orderer = new AssembliesHbmOrderer(Platform.PluginManager.Plugins);
orderer.AddToConfiguration(_cfg);
// setup default caching strategies for all classes/collections that don't have one explicitly
// specified in the mapping files
CreateDefaultCacheStrategies();
// create the session factory
_sessionFactory = _cfg.BuildSessionFactory();
Platform.Log(LogLevel.Info, "NHibernate initialization complete.");
}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:30,代码来源:PersistentStore.cs
示例20: Init
private static void Init()
{
var config = new Configuration();
config.Configure();
config.AddAssembly(Assembly.GetCallingAssembly());
_sessionFactory = config.BuildSessionFactory();
}
开发者ID:AdamPrendergast,项目名称:Squarker_ASP.NET_MVC,代码行数:7,代码来源:DatabaseManager.cs
注:本文中的ISessionFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论