Ejemplo n.º 1
0
        public SortedDictionary <System.Guid, GenesisBusiness.Order> SelectAll()
        {
            var dict = new SortedDictionary <System.Guid, GenesisBusiness.Order>();
            var db   = new Models.OrdersEntities();

            db.Configuration.LazyLoadingEnabled = false;

            //KF: There are several ways that the Orders can be combined with the Customer data to return the Customer names.

            //The orders Entity Framework could load the data using lazy-loading.  However in a display grid every orders customer would be loaded
            //one at a time.  For a large grid the performance hit would be quite large.  If several tables data were used in the grid the performance hit
            //would be even larger.

            //The customer data could be selected separately and then knitted into the grid using the customer id and CustomUnboundColumnData.  This method is most suitable
            //for static data that can be cached in memory.  For instance Customer or Order type.  This method reduces the amount of data returned from the database and so
            //improves performance.

            //I have chosen to write a stored procedure that returns the data that the grid needs.  As not every customer is needed and the data is not static it is the
            //most suitable method.


            var orders = db.SelectAllOrdersWithCustomers();

            foreach (Models.spr_SelectAllOrdersWithCustomers_Result item in orders)
            {
                Order order = new Order(item);
                order.Parent = this;

                dict.Add(item.OrderId, order);
            }

            db.Dispose();

            this.Dictionary = dict;

            return(dict);
        }