将 MS Moles 与数据上下文和存储过程结合使用,而不使用连接字符串
我刚刚开始使用 MS Moles 进行测试,并且我遵循了 jcollum(thanks) 在这个 stackoverflow 问题 此处。
但我遇到了一个问题,因为我不想在使用数据源时必须传递连接字符串:
using (TheDataContext dataContext = new TheDataContext(myConnectionString))
{
dataContext.ExecuteStoredprocedure(value, ref ValueExists);
}
我真的很喜欢这样一个事实:我只需要修改表,其他一切都为我完成。我意识到我可以只摩尔 ExecuteStoredProcedure 方法,但我想知道我是否可以以某种方式避免当我不传入连接字符串时出现的 sql 异常。或者,如果我有更好的方法来做到这一点?
因此,有没有人有解决方案,以便我可以避免放置连接字符串?提前致谢。
I have just begun to work with MS Moles for testing and I have followed the idea/pattern in which jcollum(thanks) uses a Mole for a table in this stackoverflow question here.
But I am having a problem as I do not want to have to pass a connection string when I use the datasource as such:
using (TheDataContext dataContext = new TheDataContext(myConnectionString))
{
dataContext.ExecuteStoredprocedure(value, ref ValueExists);
}
I really like the fact that I just need to mole the table and everything else is done for me. I realize I could just mole the ExecuteStoredProcedure method, but I am wondering if I could just somehow avoid the sql exception I am getting here when I do not pass in the connection string. Or, if I there is a better way to do this?
Therefore, does anyone have a solution so that I can avoid placing in the connection string? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论