1: //ADO.NET EF Example
2:
3: using System;
4: using System.Data.Linq;
5: using System.Linq;
6: using System.Collections.Generic;
7: /*
8: This Data Transfer Object created Automatically by DTOGenerator.
9: You can download DTOGenerator and get support in the project site: http://dtogenerator.codeplex.com
10: DTOGenerator developed by Shahar Gvirtz (http://weblogs.asp.net/shahar)
11: */
12:
13: namespace DTO
14: {
15: public class ProductDTO
16: {
17: public static ProductDTO GetDTOFromDALObject(ConsoleApplication3.Product src, bool GetChilds)
18: {
19: ProductDTO obj = new ProductDTO();
20: obj.Discontinued = src.Discontinued;
21: obj.ProductID = src.ProductID;
22: obj.ProductName = src.ProductName;
23: obj.QuantityPerUnit = src.QuantityPerUnit;
24: obj.ReorderLevel = src.ReorderLevel;
25: obj.UnitPrice = src.UnitPrice;
26: obj.UnitsInStock = src.UnitsInStock;
27: obj.UnitsOnOrder = src.UnitsOnOrder;
28: if(src.Category != null && GetChilds)
29: obj.Category = CategoryDTO.GetDTOFromDALObject(src.Category,false);
30: if(src.Order_Details != null && GetChilds) {
31: List<Order_DetailDTO> Order_DetailDTOlst = new List<Order_DetailDTO>();
32: src.Order_Details.ToList().ForEach(p=>Order_DetailDTOlst.Add(Order_DetailDTO.GetDTOFromDALObject(p,false)));
33: obj.Order_Details = Order_DetailDTOlst;
34: }
35:
36: if(src.Supplier != null && GetChilds)
37: obj.Supplier = SupplierDTO.GetDTOFromDALObject(src.Supplier,false);
38:
39: return obj;
40: }
41: public ConsoleApplication3.Product GetDALObject(bool IncludeChilds)
42: {
43: ConsoleApplication3.Product obj = new ConsoleApplication3.Product();
44: obj.Discontinued = Discontinued;
45: obj.ProductID = ProductID;
46: obj.ProductName = ProductName;
47: obj.QuantityPerUnit = QuantityPerUnit;
48: obj.ReorderLevel = ReorderLevel;
49: obj.UnitPrice = UnitPrice;
50: obj.UnitsInStock = UnitsInStock;
51: obj.UnitsOnOrder = UnitsOnOrder;
52: if(Category != null && IncludeChilds)
53: obj.Category = Category.GetDALObject(false);
54: if(Order_Details != null && IncludeChilds) {
55: System.Data.Objects.DataClasses.EntityCollection<ConsoleApplication3.Order_Detail> Order_Detailsgetdallst = new System.Data.Objects.DataClasses.EntityCollection<ConsoleApplication3.Order_Detail>();
56: Order_Details.ForEach(p=>Order_Detailsgetdallst.Add(p.GetDALObject(false)));
57: obj.Order_Details = Order_Detailsgetdallst; }
58:
59: if(Supplier != null && IncludeChilds)
60: obj.Supplier = Supplier.GetDALObject(false);
61:
62:
63: return obj;
64: }
65:
66: public Boolean Discontinued { get; set; }
67: public Int32 ProductID { get; set; }
68: public String ProductName { get; set; }
69: public String QuantityPerUnit { get; set; }
70: public Int16? ReorderLevel { get; set; }
71: public Decimal? UnitPrice { get; set; }
72: public Int16? UnitsInStock { get; set; }
73: public Int16? UnitsOnOrder { get; set; }
74: public DTO.CategoryDTO Category { get; set; }
75: public List<DTO.Order_DetailDTO> Order_Details { get; set; }
76: public DTO.SupplierDTO Supplier { get; set; }
77:
78:
79: }
80: }