我一直在使用DynamoDb进行ASP.NET项目,我已经从Db中提取了该项目并将其制作为新的Car对象。当我尝试填充汽车的ListBox时,似乎在ListBox中没有任何对象。
这是我所拥有的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
using Amazon.DynamoDBv2.DocumentModel;
public partial class _Default : System.Web.UI.Page
{
private static AmazonDynamoDBClient client = new AmazonDynamoDBClient();
private static string tableName = "CarTable";
private static string sampleCarReg = "05-Rn-1964";
List<car> cars = new List<car>();
protected void Page_Load(object sender, EventArgs e)
{
Amazon.DynamoDBv2.DocumentModel.Table CarTable = Amazon.DynamoDBv2.DocumentModel.Table.LoadTable(client, tableName);
GetItemOperationConfig config = new GetItemOperationConfig
{
AttributesToGet = new List<string> { "Reg", "Manufactor", "Year", "Problems" },
ConsistentRead = true
};
Document doc = CarTable.GetItem(sampleCarReg, config);
string Reg = doc["Reg"].AsString();
string Manufactor = doc["Manufactor"].AsString();
string Year = doc["Year"].AsString();
string Problems = doc["Problems"].AsString();
// string Model = doc["Model"].AsString();
car car1 = new car(Reg, Manufactor, Year, Problems);
cars.Add(car1);
lblCar.Text = car1.ToString();
lbxCars.DataSource = cars;
}
jeck猫
相关分类