本文整理汇总了C#中UnitOfWork.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.Connect方法的具体用法?C# UnitOfWork.Connect怎么用?C# UnitOfWork.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.Connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("Starting...");
using(UnitOfWork uow = new UnitOfWork()) {
Console.WriteLine("Connecting...");
uow.ConnectionString = Constants.DatabaseConnectionString;
uow.Connect();
foreach(Person p in new XPCollection<Person>(uow)) {
Console.WriteLine("Person - FirstName: {0}, LastName: {1}", p.FirstName, p.LastName);
foreach(Product product in p.Products) {
Console.WriteLine(" Product - Name: {0}, Manager: {1}", product.Name, product.Manager.FirstName + " " + product.Manager.LastName);
}
}
}
Console.WriteLine("Press Enter to close...");
Console.ReadLine();
}
示例2: LegacyDbExists
bool LegacyDbExists(UnitOfWork unitOfWork) {
try {
unitOfWork.Connect();
return true;
} catch (UnableToOpenDatabaseException) {
DevExpress.XtraEditors.XtraMessageBox.Show(
"Application will now exit because you have not created the legacy database!!!", "Exit", MessageBoxButtons.OK,
MessageBoxIcon.Error);
Application.ExitThread();
}
return false;
}
示例3: ConnectToLegacyVideoRentDB
UnitOfWork ConnectToLegacyVideoRentDB() {
var unitOfWork = new UnitOfWork {
ConnectionString = ConfigurationManager.ConnectionStrings["VideoRentLegacy"].ConnectionString,
AutoCreateOption = AutoCreateOption.None
};
try {
unitOfWork.Connect();
} catch (UnableToOpenDatabaseException) {
if (StartVideoRent(unitOfWork))
unitOfWork.Connect();
else
Application.ExitThread();
}
return unitOfWork;
}
示例4: ConnectToLegacyVideoRentDB
UnitOfWork ConnectToLegacyVideoRentDB() {
_updater.SaveResource("LegacyVideoRent.zip");
Decompress(new FileInfo("LegacyVideoRent.zip"));
var unitOfWork = new UnitOfWork {
ConnectionString = ConfigurationManager.ConnectionStrings["VideoRentLegacy"].ConnectionString,
AutoCreateOption = AutoCreateOption.None
};
unitOfWork.Connect();
return unitOfWork;
}