我正在运行一个在VS 2010 SP 1上编译的C#项目,在Windows 8机器上安装了.NET 4.5,我有一个如下所示的方法:
private IEnumerable< TModel> ExecuteAndGet< TModel>(string name,IEnumerable< SqlParameter>参数)其中TModel:new() {// < - Breakpoint 1 //非常简单代码,所以我怀疑方法调用被优化掉 //或者甚至有可能的事情。 }在不同方法的同一个类中,我调用 ExecuteAndGet 像这样:
this.ExecuteAndGet< object>([dbo]。[SomeStoredProcedure] ,参数); //< - 断点2这绝对是该方法唯一的重载。在调试模式下运行程序时,我打破了断点2.我已经尝试过常规的F5和步骤INTO,但是它完全跳过了方法,并且跳过了断点1.我不知道为什么会发生这种情况。其他调用 ExecuteAndGet 正在工作,我不明白为什么这是不同的。帮助吗?
谢谢。
解决方案你不是实际列举。尝试:
this.ExecuteAndGet< object>([dbo]。[SomeStoredProcedure],参数).ToList();
I'm running a C# project compiled against .NET 3.5 in VS 2010 SP 1 on a Windows 8 machine with .NET 4.5 installed, if that matters.
I have a method that looks like the following:
private IEnumerable<TModel> ExecuteAndGet<TModel>(string name, IEnumerable<SqlParameter> parameters) where TModel : new() { // <-- Breakpoint 1 // Non-trivial code so I doubt the method call is being optimized away // Or something if that's even possible. }In the same class in a different method I call ExecuteAndGet like so:
this.ExecuteAndGet<object>("[dbo].[SomeStoredProcedure]", parameters); // <-- Breakpoint 2That's definitely the only overload of that method. While running the program in debug mode I hit breakpoint 2. I've tried just regular "F5" and "Step INTO" but it completely skips going inside the method altogether and it skips breakpoint 1. I have no idea why this is happening. Other calls to ExecuteAndGet are working and I don't see why this is any different. Help, please?
Thanks.
解决方案You're not actually enumerating. Try:
this.ExecuteAndGet<object>("[dbo].[SomeStoredProcedure]", parameters).ToList();
更多推荐
为什么我的方法不被调用?
发布评论