- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经使用空的 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,但不知道如何访问该项目中 connectionfactory 的引用。
我认为我的问题与对 IoC 缺乏更深入的了解有关我可能在这里把事情复杂化了。
建议?
TIA
最佳答案
感谢您的反馈。我要感谢您提供如此出色的图书馆。我的问题原来是我对 IoC 缺乏理解,我不得不编写如下代码:var conn = HostContext.Container.Resolve<IDbConnection>();
conn.Open();
conn.Save<Channel>(channel);
关于c# - ServiceInterface 中的 ServiceStack Ormlite 使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34114080/
是否可以扩展 ServiceStack.ServiceInterface.Auth?添加比用户名和密码更多的属性?我已经创建了一个自定义 AuthProvider 并希望在身份验证请求中接受 3 个参
我已经使用空的 asp.net 模板创建了一个解决方案。我添加了 Ormlite 和 MySql Servicestatck 库,并在 Apphost.cs 中配置了它们 Connec
最近在做servicestack项目。当我尝试在项目中添加 open ServiceStack.ServiceInterface 时,它显示以下错误。 代码的 PFB 图片。 正如错误建议的那样,当我
我是一名优秀的程序员,十分优秀!