本文整理汇总了C#中Repository.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Dispose方法的具体用法?C# Repository.Dispose怎么用?C# Repository.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.Dispose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application_Start
protected void Application_Start()
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("da-DK");
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
if (Database.Exists("Repository"))
{
Database.SetInitializer<Repository>(new MigrateDatabaseToLatestVersion<Repository, IN.Natteravnene.dk.Migrations.Configuration>()); ;
}
else
{
Database.SetInitializer(new DataContextInitializer());
}
GlobalDbContext = new Repository();
GlobalDbContext.Database.Initialize(true);
if (!WebSecurity.Initialized) WebSecurity.InitializeDatabaseConnection("Repository", "People", "UserID", "UserName", autoCreateTables: true);
GlobalDbContext.Dispose();
ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory());
//ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactoryScope(GlobalDbContext));
ModelBinders.Binders.Add(typeof(DateTime), new DateTimeBinder());
ModelBinders.Binders.Add(typeof(DateTime?), new NullableDateTimeBinder());
}
示例2: Be_Able_To_Add_New_Entity
public void Be_Able_To_Add_New_Entity()
{
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
var cust = new Customer { Int32Id = 4 };
repo.Add(cust);
_mockSession.Verify(ms => ms.Save(cust));
SetHelperFactory(oldValue);
repo.Dispose();
}
示例3: Be_Able_To_Add_Multiple_New_Entities
public void Be_Able_To_Add_Multiple_New_Entities()
{
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
IEnumerable<Customer> customers = new[]
{
new Customer{ Int32Id = 4 },
new Customer{ Int32Id = 36 },
new Customer{ Int32Id = 90 }
};
repo.Add(customers);
_mockSession.Verify(ms => ms.Save(It.IsAny<Customer>()), Times.Exactly(3));
SetHelperFactory(oldValue);
repo.Dispose();
}
示例4: Init
public Repository Init(IAbsoluteDirectoryPath directory, RepositoryOperationMode? mode = null) {
Contract.Requires<ArgumentNullException>(directory != null);
if (File.Exists(directory.ToString()))
throw new SynqPathException("Already exists file with same name");
ConfirmEmpty(directory);
directory.MakeSurePathExists();
var repo = new Repository(directory, true);
try {
if (mode != null)
repo.Config.OperationMode = mode.Value;
repo.Save();
} catch {
repo.Dispose();
throw;
}
return repo;
}
示例5: Be_Able_To_Get_Entity_By_Id
public void Be_Able_To_Get_Entity_By_Id()
{
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
repo.GetById<Customer>(4);
_mockSession.Verify(ms => ms.Get<Customer>(4));
SetHelperFactory(oldValue);
repo.Dispose();
}
示例6: Use_Current_Session_If_Available
public void Use_Current_Session_If_Available()
{
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
_mockFactory.Verify(mf => mf.GetCurrentSession());
// restore old value of factory for other tests to work properly
SetHelperFactory(oldValue);
repo.Dispose();
}
示例7: Throw_When_Asked_To_Get_Entity_By_Guid
public void Throw_When_Asked_To_Get_Entity_By_Guid()
{
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
try
{
repo.GetById<Customer>(Guid.NewGuid());
}
finally
{
SetHelperFactory(oldValue);
repo.Dispose();
}
}
示例8: Create_New_Session_If_No_Current_Session_Available
public void Create_New_Session_If_No_Current_Session_Available()
{
_mockFactory.Setup(mf => mf.GetCurrentSession()).Throws(new HibernateException());
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
_mockFactory.Verify(mf => mf.OpenSession());
_mockSession.Verify(ms => ms.BeginTransaction());
SetHelperFactory(oldValue);
repo.Dispose();
}
示例9: Commit_Transaction_When_Owning_Session
public void Commit_Transaction_When_Owning_Session()
{
_mockFactory.Setup(mf => mf.GetCurrentSession()).Throws(new HibernateException());
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
repo.Save();
_mockTransaction.Verify(mt => mt.Commit());
SetHelperFactory(oldValue);
repo.Dispose();
}
示例10: Be_Able_To_Query_All_Entities
public void Be_Able_To_Query_All_Entities()
{
var oldValue = SetHelperFactory(_mockFactory.Object);
var repo = new Repository();
repo.All<Customer>();
_mockSession.Verify(ms => ms.Query<Customer>());
SetHelperFactory(oldValue);
repo.Dispose();
}