Good day!
I am having a hard time returning data collection with existing data (SQL Server 2012) on .Net Core ADO.NET Entity Model. Also, it does not step through breakpoint on my Ienumerable<>Get() but the breakpoint crosses through public string Get(int id). How is it possible to cross through breakpoint on IEnumerable? I also tried following this link Cannot step into a method returning IEnumerable<T>? , adding ".ToList()" on my code but it still does not cross on breakpoint. :( I have no error on my code.
Here is my code :
My ADO.NET Entity Model
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; }
}
}
My IEnumerable code (does not cross on breakpoint):
// GET api/values
[HttpGet]
public IEnumerable<tbl_employee> Get()
{
List<EmployeeEntities> EmployeesList = new List<EmployeeEntities>();
var empTable = new tbl_employee();
var temp = empTable.emp_firstname.ToString();
var employeelist = (from Employees in EmployeesList
select new tbl_employee
{ emp_firstname = empTable.emp_firstname }).ToList();
return employeelist;
}
Screenshot on trying to return IEnumerable :
My Get(id) code (crosses on breakpoint) :
// GET api/values/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value 1, value 2, value 3";
}
Screenshot on returning Get(ID) :
Will gladly appreciate any suggestions, comments, replies.
Thank you very much and have a nice day!
(UPDATE)
I tried reverting to the default static IEnumerable<>Get() and it crosses the breakpoint and returns json values. How do I do this with returning existing data on SQL Server 2012 db using ADO.NET? Thanks.
The default code I reverted back :
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2", "value3" };
}
Screenshot on the result :