public Sales_CustomerQuery <Sales_SpecialDealQuery <K, T>, T> JoinSales_Customer(JoinType joinType = JoinType.Inner, bool preloadEntities = false)
        {
            var joinedQuery = new Sales_CustomerQuery <Sales_SpecialDealQuery <K, T>, T>(Db);

            return(Join(joinedQuery, string.Concat(joinType.GetJoinString(), " [Sales].[Customers] AS {1} {0} ON", "{2}.[CustomerID] = {1}.[CustomerID]"), o => ((Sales_SpecialDeal)o)?.Sales_Customer, (e, fv, ppe) =>
            {
                var child = (Sales_Customer)ppe(QueryHelpers.Fill <Sales_Customer>(null, fv));
                if (e != null)
                {
                    ((Sales_SpecialDeal)e).Sales_Customer = child;
                }

                return child;
            }

                        , typeof(Sales_Customer), preloadEntities));
        }
        public Sales_CustomerQuery <Application_CityQuery <K, T>, T> JoinSales_Customers_PostalCityID_Application_Cities(JoinType joinType = JoinType.Inner, bool attach = false)
        {
            var joinedQuery = new Sales_CustomerQuery <Application_CityQuery <K, T>, T>(Db);

            return(JoinSet(() => new Sales_CustomerTableQuery <Sales_Customer>(Db), joinedQuery, string.Concat(joinType.GetJoinString(), " [Sales].[Customers] AS {1} {0} ON", "{2}.[CityID] = {1}.[PostalCityID]"), (p, ids) => ((Sales_CustomerWrapper)p).Id.In(ids.Select(id => (System.Int32)id)), (o, v) => ((Application_City)o).Sales_Customers_PostalCityID_Application_Cities.Attach(v.Cast <Sales_Customer>()), p => (long)((Sales_Customer)p).PostalCityID, attach));
        }