sql 查询的结果在 .net API 中显示不正确

Results of sql query are not shown correct in .net API

我有一个 sql 查询调用 stored-procedure.

存储过程在 SQL server 中正常工作。但是在 .NETforeach (var item in query_pre) 部分我得到了错误的结果。

.NET.中我有以下代码:

 public partial class get_active_call_info_ids
    {
        public int call_id { get; set; }
        public List<int> call_info_id { get; set; }
        public int call_info_timing_id { get; set; }
        public List<System.DateTime> dateOfBirth { get; set; }
        public List<string> patientName { get; set; }
        public List<string> patientId { get; set; }
        public string station_name { get; set; }

        public get_active_call_info_ids()
        {
            call_info_id = new List<int>();
            dateOfBirth = new List<System.DateTime>();
            patientName = new List<string>();
            patientId = new List<string>();
        }
    }
    public class CallRootObject
    {
        public List<get_active_call_info_ids> Calls { get; set; }
        public int StatusCode { get; set; }

        public CallRootObject()
        {
            Calls = new List<get_active_call_info_ids>();
        }
    }

                    var query_pre = entities.Database.SqlQuery<get_active_call_info_id_Result>("exec [dbo].[get_active_call_info_id] @user_id", new SqlParameter("user_id", u_id))
                        .ToList();

 //Create objects of classes to handle information
                    var queryItem = new get_active_call_info_ids();
                    var queryItems = new CallRootObject();

                    //Initialize parameters
                    int call_id_local = query_pre[0].call_id;
                    int previous_call_id_local = query_pre[0].call_id;

                    //Counter to control data manipulation

                    foreach (var item in query_pre)
                    {
                        call_id_local = item.call_id;
                        //System.Diagnostics.Debug.WriteLine(item.ToString());

                        
                            queryItem.call_info_id.Clear();
                            queryItem.patientId.Clear();
                            queryItem.patientName.Clear();
                            queryItem.dateOfBirth.Clear();
                        }

                        queryItem.call_id = item.call_id;
                        queryItem.call_info_id.Add(item.call_info_id);
                        queryItem.call_info_timing_id = item.call_info_timing_id;
                        queryItem.patientId.Add(item.patientId);
                        queryItem.patientName.Add(item.patientName);
                        queryItem.dateOfBirth.Add(item.dateOfBirth);
                        queryItem.station_name = item.station_name;

                    };

我在 SQL server 中的 stored-procedure 工作正常:

然而,API 的结果如下:

"{\"Calls\":[{\"call_id\":91390,\"call_info_id\":[20],\"call_info_timing_id\":30,\"dateOfBirth\":[\"2020-09-23T17:54:04.817\"],\"patientName\":[\"N/A\"],\"patientId\":[\"987654\"],\"station_name\":\"ΣΤΑΘΜΟΣ ΠΑΛΙΟΥ ΝΟΣ. ΛΕΜΕΣΟΥ\"},{\"call_id\":91391,\"call_info_id\":[20],\"call_info_timing_id\":30,\"dateOfBirth\":[\"2020-09-23T17:54:04.817\"],\"patientName\":[\"N/A\"],\"patientId\":[\"987654\"],\"station_name\":\"ΣΤΑΘΜΟΣ ΠΑΛΙΟΥ ΝΟΣ. ΛΕΜΕΣΟΥ\"}],\"StatusCode\":1}"

我找到了解决方案。而不是

queryItem.call_info_id.Clear();
queryItem.patientId.Clear();
queryItem.patientName.Clear();
queryItem.dateOfBirth.Clear();

我用过:

queryItem = new get_active_call_info_ids();