【发布时间】:2015-12-06 22:49:46
【问题描述】:
我使用空的 asp.net 模板创建了一个解决方案。 我添加了 Ormlite 和 MySql Servicestatck 库并在 Apphost.cs 中配置了它们
ConnectionStringSettings connstring = ConfigUtils.GetConnectionStringSetting("Nice2NoConnection");
container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(connstring.ToString(), MySqlDialectProvider.Instance));
// Below we refer to the connection factory that we just registered
// with the container and use it to create our table(s).
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
// We’re just creating a single table, but you could add
// as many as you need. Also note the “overwrite: false” parameter,
// this will only create the table if it doesn’t already exist.
db.CreateTable<Channel>(overwrite: false);
我无法弄清楚如何访问在 ServiceInterface 项目中包含 Save() 的 OrmliteWriteExtensions。我尝试在那里添加 Ormlite 和 MySql 但不知道如何访问该项目中连接工厂的引用。
我认为我的问题与对 IoC 缺乏更深入的了解有关 我可能在这里把事情复杂化了。
建议?
TIA
【问题讨论】:
标签: c# mysql ormlite-servicestack