本文整理汇总了C#中IDbConnectionFactory.Run方法的典型用法代码示例。如果您正苦于以下问题:C# IDbConnectionFactory.Run方法的具体用法?C# IDbConnectionFactory.Run怎么用?C# IDbConnectionFactory.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbConnectionFactory
的用法示例。
在下文中一共展示了IDbConnectionFactory.Run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecreateTables
private void RecreateTables(IDbConnectionFactory factory)
{
factory.Run(x =>
{
using (var transaction = x.BeginTransaction())
{
try
{
//core tables
x.DropAndCreateTables(typeof(VCALENDAR), typeof(VEVENT), typeof(VTODO), typeof(VFREEBUSY), typeof(FREEBUSY), typeof(VJOURNAL), typeof(VTIMEZONE), typeof(STANDARD), typeof(DAYLIGHT), typeof(AUDIO_ALARM), typeof(DISPLAY_ALARM), typeof(EMAIL_ALARM), typeof(ORGANIZER), typeof(ATTENDEE), typeof(COMMENT), typeof(RELATEDTO), typeof(ATTACH_BINARY), typeof(ATTACH_URI), typeof(CONTACT), typeof(RDATE), typeof(EXDATE), typeof(RECUR), typeof(RECURRENCE_ID), typeof(REQUEST_STATUS), typeof(RESOURCES), typeof(TZNAME));
//3NF relational tables
x.DropAndCreateTables(typeof(REL_CALENDARS_EVENTS), typeof(REL_CALENDARS_TODOS), typeof(REL_CALENDARS_FREEBUSIES), typeof(REL_CALENDARS_JOURNALS), typeof(REL_CALENDARS_TIMEZONES), typeof(REL_EVENTS_ATTACHBINS), typeof(REL_EVENTS_ATTACHURIS), typeof(REL_EVENTS_ATTENDEES), typeof(REL_EVENTS_AUDIO_ALARMS), typeof(REL_EVENTS_COMMENTS), typeof(REL_EVENTS_CONTACTS), typeof(REL_EVENTS_DISPLAY_ALARMS), typeof(REL_EVENTS_EMAIL_ALARMS), typeof(REL_EVENTS_EXDATES), typeof(REL_EVENTS_RDATES), typeof(REL_EVENTS_RELATEDTOS), typeof(REL_EVENTS_REQSTATS), typeof(REL_EVENTS_RESOURCES), typeof(REL_TODOS_ATTACHBINS), typeof(REL_TODOS_ATTACHURIS), typeof(REL_TODOS_ATTENDEES), typeof(REL_TODOS_AUDIO_ALARMS), typeof(REL_TODOS_COMMENTS), typeof(REL_TODOS_CONTACTS), typeof(REL_TODOS_DISPLAY_ALARMS), typeof(REL_TODOS_EMAIL_ALARMS), typeof(REL_TODOS_EXDATES), typeof(REL_TODOS_RDATES), typeof(REL_TODOS_RELATEDTOS), typeof(REL_TODOS_REQSTATS), typeof(REL_TODOS_RESOURCES), typeof(REL_FREEBUSIES_ATTACHBINS), typeof(REL_FREEBUSIES_ATTACHURIS), typeof(REL_FREEBUSIES_ATTENDEES), typeof(REL_FREEBUSIES_COMMENTS), typeof(REL_FREEBUSIES_REQSTATS), typeof(REL_FREEBUSIES_VFREEBUSIES), typeof(REL_JOURNALS_ATTACHBINS), typeof(REL_JOURNALS_ATTACHURIS), typeof(REL_JOURNALS_ATTENDEES), typeof(REL_JOURNALS_COMMENTS), typeof(REL_JOURNALS_CONTACTS), typeof(REL_JOURNALS_EXDATES), typeof(REL_JOURNALS_RDATES), typeof(REL_JOURNALS_RELATEDTOS), typeof(REL_JOURNALS_REQSTATS), typeof(REL_JOURNALS_RESOURCES), typeof(REL_EALARMS_ATTACHBINS), typeof(REL_EALARMS_ATTACHURIS), typeof(REL_EALARMS_ATTENDEES), typeof(REL_TIMEZONES_STANDARDS), typeof(REL_TIMEZONES_DAYLIGHT), typeof(REL_STANDARDS_COMMENTS), typeof(REL_STANDARDS_RDATES), typeof(REL_STANDARDS_TZNAMES), typeof(REL_DAYLIGHTS_COMMENTS), typeof(REL_DAYLIGHTS_RDATES), typeof(REL_DAYLIGHTS_TZNAMES));
transaction.Commit();
}
catch (ApplicationException)
{
transaction.Rollback();
throw;
}
catch (InvalidOperationException)
{
transaction.Rollback();
throw;
}
}
});
}
示例2: Seed
public static void Seed(IDbConnectionFactory dbFactory)
{
dbFactory.Run(db =>
{
CategorySeeder.Seed(db);
PrioritySeeder.Seed(db);
StatusSeeder.Seed(db);
});
}
示例3: DeleteAllRowsFromTables
private void DeleteAllRowsFromTables(IDbConnectionFactory factory)
{
factory.Run(x =>
{
using (var transaction = x.BeginTransaction())
{
try
{
//core tables
x.DeleteAll(typeof(VCALENDAR));
x.DeleteAll(typeof(VEVENT));
x.DeleteAll(typeof(VTODO));
x.DeleteAll(typeof(VFREEBUSY));
x.DeleteAll(typeof(FREEBUSY));
x.DeleteAll(typeof(VJOURNAL));
x.DeleteAll(typeof(VTIMEZONE));
x.DeleteAll(typeof(STANDARD));
x.DeleteAll(typeof(DAYLIGHT));
x.DeleteAll(typeof(AUDIO_ALARM));
x.DeleteAll(typeof(DISPLAY_ALARM));
x.DeleteAll(typeof(EMAIL_ALARM));
x.DeleteAll(typeof(ATTENDEE));
x.DeleteAll(typeof(COMMENT));
x.DeleteAll(typeof(RELATEDTO));
x.DeleteAll(typeof(ATTACH_BINARY));
x.DeleteAll(typeof(ATTACH_URI));
x.DeleteAll(typeof(CONTACT));
x.DeleteAll(typeof(RDATE));
x.DeleteAll(typeof(EXDATE));
x.DeleteAll(typeof(REQUEST_STATUS));
x.DeleteAll(typeof(RESOURCES));
x.DeleteAll(typeof(TZNAME));
transaction.Commit();
}
catch (ApplicationException)
{
transaction.Rollback();
throw;
}
catch (InvalidOperationException)
{
transaction.Rollback();
throw;
}
}
});
}
示例4: InitTests
public void InitTests()
{
dbFactory = new OrmLiteConnectionFactory(":memory:", false, SqliteOrmLiteDialectProvider.Instance);
dbFactory.Run(db => db.CreateTable<Priority>());
var users = new InMemoryAuthRepository();
personRepository = new PersonRepository(users, null);
;
}
示例5: InitTests
public void InitTests()
{
dbFactory = new OrmLiteConnectionFactory(":memory:", false, SqliteOrmLiteDialectProvider.Instance);
dbFactory.Run(db => db.CreateTable<Comment>());
var users = new InMemoryAuthRepository();
personRepository = new PersonRepository(users, null);
issueRepository = new IssueRepository(dbFactory, personRepository);
// TODO add issues
}