您好,抱歉我的英语不好,我在C#Firebase上工作,我在检索数据时遇到问题
我的数据库在这里;
[-] "Product":
[-] "1":
Brand: "Y Brand"
BuyPrice: "1500$"
Category: "Software"
Id: "22"
InStock: "15"
Model: "x1500"
SellPrice: "1600$"
SerialNumber: "4564564654"
[-] "2":
Brand: "X Brand"
BuyPrice: "1500$"
Category: "Hardware"
Id: "245"
InStock: "45"
Model: "x1600"
SellPrice: "1700$"
SerialNumber: "46848564654"
(我无法发布图片,因为我需要至少10个信誉排名)
此代码检索“ Products /” + int中的数据 但我无法获得产品标题
try
{
i++;
con.resp = await con.client.GetAsync("Product/" + i);
Product prdct = con.resp.ResultAs<Product>();
DataRow row = dt.NewRow();
row["ID"] = prdct.Id;
id = prdct.Id;
row["Kategori"] = prdct.Category;
row["Marka"] = prdct.Brand;
row["Model"] = prdct.Model;
row["Stok"] = prdct.InStock;
row["Alış Fiyatı"] = prdct.BuyPrice;
row["Satış Fiyatı"] = prdct.SellPrice;
row["Seri Numarası"] = prdct.SerialNumber;
dt.Rows.Add(row);
tolerance = 0;
}
我如何获得此书名?像在Access或Sql中一样(从产品中选择ID)
[-] "Product":
[+] "1"
[+] "2"
答案 0 :(得分:0)
我已经解决了这个问题:
数据库:
[-] "Products":
[-] "All":
Brand: "X Brand,Y Brand"
BuyPrice: "1500$,1600$"
Category: "Software,Hardware"
Id: "22,23"
InStock: "15,1675"
Model: "x1500,x1600"
SellPrice: "1600$,1700$"
SerialNumber: "123,123"
我可以获取这些数据,并为每个孩子导出到“ string [] id,string []品牌”,然后下面的代码获取所有数据在1秒以内
Product prdct = con.resp.ResultAs<Product>();
getID = prdct.Id.Split(',');
getCategory = prdct.Category.Split(',');
getBrand = prdct.Brand.Split(',');
getModel = prdct.Model.Split(',');
getSellPrice = prdct.SellPrice.Split(',');
getBuyPrice = prdct.BuyPrice.Split(',');
getInStock = prdct.InStock.Split(',');
getSerialNumber = prdct.SerialNumber.Split(',');
try
{
for (int i = 0; i < GetID.Length; i++)
{
DataRow row = dt.NewRow();
row["ID"] = GetID.GetValue(i);
row["Kategori"] = getCategory.GetValue(i);
row["Marka"] = GetBrand.GetValue(i);
row["Model"] = GetModel.GetValue(i);
row["Stok"] = GetInStock.GetValue(i);
row["Alış Fiyatı"] = GetBuyPrice.GetValue(i);
row["Satış Fiyatı"] = GetSellPrice.GetValue(i);
row["Seri Numarası"] = getSerialNumber.GetValue(i);
dt.Rows.Add(row);
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}