我是 MongoDB 的新手,我一直在认真阅读使用 MongoDB 2.2 和官方 C# 驱动程序的初学者指南http://www.codeproject.com/Articles/524602/Beginners-guide-to-using-MongoDB官
一切似乎都很顺利,除了我不确定如何处理 MongoDB Null 值
这是我的数据结构
public class DataStructure
{
public ObjectId _id { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedOn { get; set; }
public string ClaimId { get; set; }
public string Status { get; set; }
public string FmcCity { get; set; }
public string FmcState { get; set; }
public Int32 TestType { get; set; }
public List<LineItemStructure> LineItems { get; set; …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个通用的 SqlDataReader,它将一个包含 33 列的表转换为一个列表。我希望每个列表项都包含每行的所有 33 个列值。
但是,我的代码将每个值分配给一个单独的列表项。
因此,我有 33,000 个列表项,而不是 1000 个列表项 = 1000 行数据。
我更喜欢在数据表上使用列表,因为我需要做的列表比较要简单得多。
我怎样才能有 1000 个列表项,每个列表项有 33 个值?
public static List<string> loadSQL(String query, String connectString)
{
List<string> dataList = new List<string>();
using (SqlConnection connection = new SqlConnection(connectString))
{
using (SqlCommand command = new SqlCommand(query, connection))
{
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i ++)
{
dataList.Add(Convert.ToString(reader.GetValue(i)));
}
}
}
}
return dataList;
}
}
Run Code Online (Sandbox Code Playgroud)
... …