Populating objects in C#
Posted
by acadia
on Stack Overflow
See other posts from Stack Overflow
or by acadia
Published on 2010-06-11T18:13:24Z
Indexed on
2010/06/11
18:22 UTC
Read the original article
Hit count: 497
c#
Hello, I have Order,OrderDetails and OrderStatus objects as shown below:
public class Order
{
public override int OrderId { get; set; }
public string FName { get; set; }
public string MName { get; set; }
public string LName { get; set; }
public string Street { get; set; }
public string City { get; set; }
public List<OrderDetails> OrderDetails { get; set; };
}
public class OrderDetails
{
public override int OrderdetailsId { get; set; }
public int OrderId { get; set; }
public int ProductID { get; set; }
public int Qty { get; set; }
public List<OrderStatus> OrderStat { get; set; };
}
public class OrderStatus
{
public override int OrderdetailsStatusId { get; set; }
public int OrderdetailsId { get; set; }
public int StatusID { get; set; }
}
I cannot use LinQ. I want to populate the order object like we do in LinQ.
How do I populate all all the properties in Order object: for eg.
Order o =new Order();
o.FName="John";
o.LName="abc";
o.Street="TStreet";
o.City="Atlanta";
then o.Orderdetails.Add(orderdetails)
How do I do that here in C# when not using LinQ.
© Stack Overflow or respective owner