我有一个客户类型对象列表,当我遍历该列表时,我希望能够遍历每个客户的属性。然后我想将该属性值打印为字符串。我收到 StackOverFlowException 错误。
让我先说:
提前致谢!
using Dapper;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Xml.Linq;
using System.Reflection.Emit;
using System.Reflection;
using System.Collections;
namespace AtoCLib
{
public class DataAccessLayer
{
public static List<Customer> GetCustomerList(string startChar)
{
string sql = $"SELECT TOP (10) P.LastName, [CustomerID],[PersonID] ,[StoreID] ,[TerritoryID] ,[AccountNumber] FROM [AdventureWorks2017].[Sales].[Customer] C INNER JOIN [Person].[Person] P ON C.CustomerID = P.BusinessEntityID WHERE P.LastName >= '{startChar}'";
List<Customer> CustomerList = new List<Customer>();
try
{
using (var connection = new SqlConnection("Data Source=SHCP-2035;Initial Catalog=AdventureWorks2017;Integrated Security=True"))
{ …Run Code Online (Sandbox Code Playgroud)