예제 #1
0
        private static IEnumerable <Tuple <IS5InvAssembled, QryAccount> > MakePairs(IEnumerable <IS5InvAssembled> InvAss, IEnumerable <QryAccount> accts)
        {
            Func <QryAccount, int> QryAccount_Index = (record) =>
            {
                return(record.AUnique);
            };

            IEnumerable <Tuple <IS5InvAssembled, QryAccount> > result = GenericJoins <IS5InvAssembled, QryAccount, int>
                                                                        .InnerJoin(InvAss, accts, IS5InvAssembled_Indexes.SupplierUnique_Key, QryAccount_Index);

            return(result);
        }
        public void Test_creating_Tuples_as_a_way_of_attaching_wholesaler_to_Assembled_Inventory()
        {
            // B: Attach BankInfo / wholesaler to Assembled Inventory to make InvAss, wholesaler pairs
            //   - UpdateProcess<TCommon, TKey> usage via example here: Test_GetUpdatesByCommonFields_OneOfTwoRecordsChanges()

            // UpdateProcess isn't what we use here as the pattern is different.

            // Use the Generic Join functionality that creates tuples instead
            const int    commonId = 3;
            const string matching_supplier_code = "matching_code";

            S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item();

            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();
            var First = InvAss.First();

            First.Inv.Supplier = commonId;
            Assert.AreEqual(commonId, InvAss.First().Inv.Supplier); // confirm source has change

            QryAccount acct = new QryAccount();

            acct.AName    = "Test Matching Supplier";
            acct.AUnique  = commonId; // save as above
            acct.BankInfo = matching_supplier_code;

            List <QryAccount> accts = new List <QryAccount>();

            accts.Add(acct);

            Func <QryAccount, int> QryAccount_Index = (record) =>
            {
                return(record.AUnique);
            };

            IEnumerable <Tuple <IS5InvAssembled, QryAccount> > result = GenericJoins <IS5InvAssembled, QryAccount, int>
                                                                        .InnerJoin(InvAss, accts, IS5InvAssembled_Indexes.SupplierUnique_Key, QryAccount_Index);

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(commonId, result.First().Item1.Inv.Supplier);
            Assert.AreEqual(matching_supplier_code, result.First().Item2.BankInfo);
        }