Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Web API-ADO.NET在.NET核心数据收集中不返回,也不在断点上单步执行_C#_Asp.net_Asp.net Web Api_.net Core_Ado.net Entity Data Model - Fatal编程技术网

C#Web API-ADO.NET在.NET核心数据收集中不返回,也不在断点上单步执行

C#Web API-ADO.NET在.NET核心数据收集中不返回,也不在断点上单步执行,c#,asp.net,asp.net-web-api,.net-core,ado.net-entity-data-model,C#,Asp.net,Asp.net Web Api,.net Core,Ado.net Entity Data Model,你好 我很难在.Net核心ADO.Net实体模型上使用现有数据(SQL Server 2012)返回数据收集。此外,它不会单步通过myIenumerableGet()上的断点,但断点会穿过公共字符串Get(int id)。如何穿越IEnumerable上的断点?我还尝试跟随此链接,在代码中添加“.ToList()”,但它在断点处仍然没有交叉:(我的代码没有错误 这是我的密码: 我的ADO.NET实体模型 namespace EmployeeDataAccess { using Syste

你好

我很难在.Net核心ADO.Net实体模型上使用现有数据(SQL Server 2012)返回数据收集。此外,它不会单步通过myIenumerableGet()上的断点,但断点会穿过公共字符串Get(int id)。如何穿越IEnumerable上的断点?我还尝试跟随此链接,在代码中添加“.ToList()”,但它在断点处仍然没有交叉:(我的代码没有错误

这是我的密码:

我的ADO.NET实体模型

namespace EmployeeDataAccess
{
    using System;
    using System.Collections.Generic;

    public partial class tbl_employee
    {
        public long emp_id { get; set; }
        public Nullable<long> group_id { get; set; }
        public Nullable<long> company_id { get; set; }
        public Nullable<long> RC_id { get; set; }
        public string emp_globalno { get; set; }
        public string emp_siteno { get; set; }
        public string emp_prefix { get; set; }
        public string emp_lastname { get; set; }
        public string emp_firstname { get; set; }
        public string emp_middlename { get; set; }
        public string emp_suffix { get; set; }
    }
}
返回Get(ID)时的屏幕截图:

非常感谢您的建议、评论和回复

非常感谢你,祝你今天愉快

(更新)

我尝试还原到默认的静态IEnumerableGet(),它跨越断点并返回json值。如何使用ADO.NET返回SQL Server 2012 db上的现有数据?谢谢

我还原回的默认代码:

[HttpGet]
public IEnumerable<string> Get()
{
    return new string[] { "value1", "value2", "value3" };
}
[HttpGet]
公共IEnumerable Get()
{
返回新字符串[]{“value1”、“value2”、“value3”};
}
结果截图:


您的WebApiConfig.cs看起来像什么?因为您的API中有多个HTTP GET请求,您可能需要修改您的路由-请参阅问题的答案。您好,先生@Poosh!首先感谢您的回复。我尝试添加路由,但仍然是一样的:(另外,我尝试还原到默认的静态IEnumerable,它现在跨越了断点并返回结果。在返回SQL Server数据库上的现有数据时如何执行此操作?谢谢先生!尝试在
Get()中引发异常)
函数并查看发生了什么。同时清理解决方案,然后尝试运行它。它应该返回null,因为您不应该在
员工列表中有任何内容。
// GET api/values/5
[HttpGet("{id}")]
public string Get(int id)
{
    return "value 1, value 2, value 3";
}
[HttpGet]
public IEnumerable<string> Get()
{
    return new string[] { "value1", "value2", "value3" };
}