本文整理汇总了C#中ServiceStack.OrmLite.OrmLiteConnectionFactory.Run方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.Run方法的具体用法?C# OrmLiteConnectionFactory.Run怎么用?C# OrmLiteConnectionFactory.Run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.OrmLite.OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.Run方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MetricService
public MetricService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db => db.CreateTable<Metric>(overwrite: false));
_factory.Run(db => db.CreateTable<Message>(overwrite: false));
_factory.Run(db => db.CreateTable<Trend>(overwrite: false));
}
示例2: FileSystemQueue
public FileSystemQueue(string baseDirectory, string connectionString, bool includSubdirectories = true)
{
_baseDirectory = baseDirectory;
_connectionString = connectionString;
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db => db.CreateTable<WatchedFile>(overwrite: false));
}
示例3: QuestionAnswerService
public QuestionAnswerService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db =>
{
db.CreateTable<QuestionAnswer>(overwrite: false);
});
var svc = new AnswerService(connectionString);
}
示例4: ProfileService
public ProfileService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db =>
{
db.CreateTable<ProfileAuthData>(overwrite: false);
db.CreateTable<Profile>(overwrite: false);
db.CreateTable<Position>(overwrite: false);
db.CreateTable<Company>(overwrite: false);
});
}
示例5: SurveyService
public SurveyService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db =>
{
db.CreateTable<Survey>(overwrite: false);
if (db.Count<Survey>() == 0)
{
db.Insert<Survey>(new Survey { Id = 1, Name = "My First Survey", Description = "This is the first survey.", ButtonText = "Let's Get Started!"});
}
});
var svc = new SegmentService(connectionString);
}
示例6: SegmentService
public SegmentService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db =>
{
db.CreateTable<Segment>(overwrite: false);
if (db.Count<Segment>() == 0)
{
db.Insert<Segment>(new Segment { Id = 1, SurveyId = 1, Order = 1, Name = "First Questions", Description = "Answer some simple questions.", ButtonText = "Start" });
db.Insert<Segment>(new Segment { Id = 2, SurveyId = 1, Order = 2, Name = "Second Questions", Description = "Answer some more complex questions.", ButtonText = "Start" });
}
});
var svc = new QuestionService(connectionString);
}
示例7: QuestionService
public QuestionService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db =>
{
db.CreateTable<Question>(overwrite: false);
if (db.Count<Question>() == 0)
{
db.Insert<Question>(new Question { Id = 1, Order = 1, SegmentId = 1, Text = "What is your favorite color?" });
db.Insert<Question>(new Question { Id = 2, Order = 2, SegmentId = 1, Text = "What is your quest?" });
db.Insert<Question>(new Question { Id = 3, Order = 1, SegmentId = 2, Text = "One more question?" });
}
});
var svc = new AnswerService(connectionString);
}
示例8: AnswerService
public AnswerService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db =>
{
db.CreateTable<Answer>(overwrite: false);
if (db.Count<Answer>() == 0)
{
db.Insert<Answer>(new Answer { Id = 1, QuestionId = 1, Text = "Green" });
db.Insert<Answer>(new Answer { Id = 2, QuestionId = 1, Text = "Yellow" });
db.Insert<Answer>(new Answer { Id = 3, QuestionId = 2, Text = "I seek the grail." });
db.Insert<Answer>(new Answer { Id = 4, QuestionId = 2, Text = "I don't know." });
db.Insert<Answer>(new Answer { Id = 5, QuestionId = 3, Text = "Yes" });
db.Insert<Answer>(new Answer { Id = 6, QuestionId = 3, Text = "No" });
}
});
}
示例9: FileSystemMonitor
public FileSystemMonitor(string baseDirectory, string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db => db.CreateTable<WatchedFile>(overwrite: false));
_watcher = new FileSystemWatcher();
_watcher.Path = baseDirectory;
_watcher.IncludeSubdirectories = true;
// we only care about file changes, not directories and we only care about size changes and writes
_watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size | NotifyFilters.FileName;
//// Only watch text files.
//_watcher.Filter = "*.txt";
_watcher.Changed += new FileSystemEventHandler(OnChanged);
_watcher.Created += new FileSystemEventHandler(OnCreated);
_watcher.Deleted += new FileSystemEventHandler(OnDeleted);
_watcher.Renamed += new RenamedEventHandler(OnRenamed);
_watcher.EnableRaisingEvents = true;
}
示例10: Save
public void Save(string ticker, string source, bool quarterly, string description)
{
var factory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["StockScreenerConnection"].ConnectionString, SqlServerDialect.Provider);
factory.Run(db => db.CreateTable<DiscountCashFlowHeader>(overwrite: false));
factory.Run(db => db.CreateTable<DiscountCashFlowYear>(overwrite: false));
using (IDbConnection db = factory.OpenDbConnection())
{
var headers = db.Select<DiscountCashFlowHeader>(h => h.Ticker == ticker && h.Source == source && h.IsQuarterly == quarterly);
db.Delete<DiscountCashFlowHeader>(h => h.Ticker == ticker && h.Source == source && h.IsQuarterly == quarterly);
if (null != headers)
{
foreach (var h in headers)
{
db.Delete<DiscountCashFlowYear>(y => y.DiscoutCashFlowHeaderId == h.Id);
}
}
// create header
DiscountCashFlowHeader header = new DiscountCashFlowHeader
{
Ticker = ticker,
IsQuarterly = quarterly,
Source = source,
Description = description,
StartingFcF = this.FreeCashFlow,
GrowthRate = this.GrowthRate,
DiscountRate = this.DiscountRate,
TerminalGrowthRate = this.TerminalGrowthRate,
NetDebt = this.NetDebt,
SharesOutstanding = this.SharesOutstanding,
GrowthTerminalValue = this.GrowthTerminalValue,
TenYearTerminalValue = this.TenYearTerminalValue,
GrowthEnterpriseValue = this.GrowthEnterpriseValue,
TenYearEnterpriseValue = this.TenYearEnterpriseValue
};
db.Insert(header);
header.Id = (int) db.GetLastInsertId();
// create yearly records
foreach (int i in this.FutureFreeCashFlow.Keys)
{
DiscountCashFlowYear dcfy = new DiscountCashFlowYear
{
DiscoutCashFlowHeaderId = header.Id,
FutureFreeCashFlow = this.FutureFreeCashFlow[i],
PresentFreeCashFlow = this.PresentFreeCashFlow[i],
TerminalFreeCashFlow = this.TerminalFreeCashFlow[i],
TerminalPresentFreeCashFlow = this.TerminalPresentFreeCashFlow[i]
};
db.Insert(dcfy);
}
}
}
示例11: FinancialModelService
public FinancialModelService()
{
_factory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["StockScreenerConnection"].ConnectionString, SqlServerDialect.Provider);
_factory.Run(db => db.CreateTable<GrahamAnalysis>(overwrite: false));
_metricService = new FinancialMetricService();
}
示例12: PluginSettingsService
public PluginSettingsService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db => db.CreateTable<PluginSettings>(overwrite: false));
}
示例13: Main
public static void Main (string[] args)
{
var strCon = ConfigUtils.GetConnectionString("ApplicationDb");
string tmp = strCon;
Console.WriteLine("Digite la cadena de conexion [{0}] Enter para continuar", strCon);
strCon= Console.ReadLine();
if(strCon.IsNullOrEmpty()) strCon=tmp;
OrmLiteConfig.DialectProvider = MySqlDialect.Provider;
var dbFactory = new OrmLiteConnectionFactory(strCon);
OrmLiteAuthRepository authRepo = new OrmLiteAuthRepository( dbFactory);
AuthRepoProxy rp = new AuthRepoProxy(dbFactory, null);
rp.CreateAuthTables(authRepo,false);
rp.SetEngine (authRepo);
string password = rp.CreateRandomPassword(8);
tmp = password;
Console.WriteLine("Digite la clave para {0} [{1}] Enter para continuar", "admin", password);
password= Console.ReadLine();
if(password.IsNullOrEmpty()) password=tmp;
password= rp.CreateAdminUser(authRepo, "Admin", "App", "[email protected]", password);
//
password = rp.CreateRandomPassword(8);
tmp = password;
Console.WriteLine("Digite la clave para {0} [{1}] Enter para continuar", "user", password);
password= Console.ReadLine();
if(password.IsNullOrEmpty()) password=tmp;
UserAuth user = new UserAuth{ UserName="user", Email="[email protected]"};
password= rp.CreateUser (authRepo, user,password);
Console.WriteLine(password);
dbFactory.Run (c => {
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Radicar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Radicar", Title = "Recepcionista"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Asignar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Asignar", Title = "Secretario General"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Solucionar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Solucionar", Title = "Abogado"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Firmar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Firmar", Title = "Abogado"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="RegistrarFirmar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "RegistrarFirmar", Title = "Recepcionista"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Alistar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Alistar", Title = "Recepcionista"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Entregar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Entregar", Title = "Mensajero"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Cerrar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Cerrar", Title = "Recepcionista"});
if(c.FirstOrDefault<AuthRole>(f=>f.Name=="Consultar")==default(AuthRole))
c.Insert<AuthRole>(new AuthRole{Name = "Consultar", Title = "Público"});
});
}
示例14: SubscriberService
public SubscriberService(string connectionString)
{
_factory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);
_factory.Run(db => db.CreateTable<Subscriber>(overwrite: false));
}