Jfisher387
Member
- Joined
- Dec 14, 2022
- Messages
- 21
- Programming Experience
- Beginner
Hello,
I have a mongoDB collection of orders. Inside each order is a list of items that need purchased. I successfully have saved my orders to a collection. Now I would like to browse through my orders and view the contents of each order.I would of guessed I was able to access the list inside of
Here is what I have currently.
And my classes that structure the data
I have a mongoDB collection of orders. Inside each order is a list of items that need purchased. I successfully have saved my orders to a collection. Now I would like to browse through my orders and view the contents of each order.I would of guessed I was able to access the list inside of
toolList
but doesn't seem to work as expected.Here is what I have currently.
C#:
private void ordersPage_Load(object sender, System.EventArgs e)
{
Owner.Hide();
//ResizeColumns();
List<Order> list = ordersCollection.AsQueryable().ToList();
orderListDGV.DataSource = list;
}
private void orderListDGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
int index = orderListDGV.CurrentCell.RowIndex;
string text = Convert.ToString(orderListDGV[1, index].Value);
var filter = Builders<Order>.Filter.Eq("Po", text);
var toolList = ordersCollection.Find(filter).ToList<Order>();
currentOrder.DataSource = toolList;
}
And my classes that structure the data
C#:
public class OrderItem
{
[BsonElement("Type")]
public string Type { get; set; }
[BsonElement("Vendor")]
public string Vendor { get; set; }
[BsonElement("Description")]
public string Description { get; set; }
[BsonElement("Cost")]
public double Cost { get; set; }
[BsonElement("Order Qty")]
public int OrderQty { get; set; }
[BsonElement("Serial")]
public int Serial { get; set; }
[BsonElement("PID")]
public string PID { get; set; }
}
public class Order
{
public Order(List<OrderItem> listOfItems, string po, double orderTotal, DateTime timeOfOrder)
{
OrderItemList = listOfItems;
Po = po;
OrderTotal = orderTotal;
OrderDate = timeOfOrder;
}
public ObjectId Id { get; set; }
[BsonElement("Order")]
public List<OrderItem> OrderItemList { get; set; }
[BsonElement("PO")]
public string Po { get; set; }
[BsonElement("Order Total")]
public double OrderTotal { get; set; }
[BsonElement("Date")]
public DateTime OrderDate { get; set; }
}