static async Task X() { var iMapper = Mapper.GetMapper(); var one = new DatabaseOneContext(); using (var two = new DatabaseTwoContext()) { var jCategories = two.JosCategories.Where(i => i.Id > 1).ToList(); int maxJCategories = one.JosCategories.Max(i => i.Id); jCategories.ForEach(i => { i.Id += maxJCategories; if (i.ParentId != 1) { i.ParentId += maxJCategories; } one.JosCategories.Add(iMapper.Map(i, new JosCategory())); }); one.SaveChanges(); var jContents = two.JosContents.ToList(); int maxContents = one.JosContents.Max(i => i.Id); jContents.ForEach(i => { i.Id += maxContents; i.Catid += maxJCategories; one.JosContents.Add(iMapper.Map(i, new JosContent { Parentid = "", TitleAlias = "", Mask = "", Sectionid = "", })); }); one.SaveChanges(); var engine = new Engine.Engine(one, two, iMapper); try { var custom = new Task <int>(() => { int maxCustom = engine .MergeRelationSelf <JosVirtuemartCustom, DatabaseTwo.DatabaseTwo.JosVirtuemartCustom>( i => i.VirtuemartCustomId, "VirtuemartCustomId", "CustomParentId"); return(maxCustom); }); var manufacture = new Task <int>(() => { var maxManufacture = engine .MergeStatic <JosVirtuemartManufacturer, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturer>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId"); return(maxManufacture); }); var media = new Task <int>(() => { var maxMedia = engine .MergeStatic <JosVirtuemartMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartMedia>(i => i.VirtuemartMediaId, j => j.VirtuemartMediaId > 1, "VirtuemartMediaId"); return(maxMedia); }); var product = new Task <int>(() => { // run parallel var maxProduct = engine .MergeRelationSelf <JosVirtuemartProduct, DatabaseTwo.DatabaseTwo.JosVirtuemartProduct>(i => i.VirtuemartProductId, "VirtuemartProductId", "ProductParentId"); return(maxProduct); }); var category = new Task <int>(() => { // run parallel var maxCategory = engine .MergeStatic <JosVirtuemartCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCategory>(i => i.VirtuemartCategoryId, "VirtuemartCategoryId"); return(maxCategory); }); var calc = new Task <int>(() => { int maxCalc = engine .MergeStatic <JosVirtuemartCalc, DatabaseTwo.DatabaseTwo.JosVirtuemartCalc>(i => i.VirtuemartCalcId, "VirtuemartCalcId"); return(maxCalc); }); custom.Start(); calc.Start(); category.Start(); product.Start(); media.Start(); manufacture.Start(); await Task.WhenAll(custom, category, product, media, manufacture, calc); var maxCategory = category.Result; var maxCustom = custom.Result; var maxManufacture = manufacture.Result; var maxMedia = media.Result; var maxProduct = product.Result; var maxCalc = calc.Result; // run parallel var maxPaymentMethod = engine .MergeStatic <JosVirtuemartPaymentmethod, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethod> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId"); engine .MergeJoinSelfTable <JosVirtuemartCategoryCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCategoryCategory>(i => i.Id, "Id", "CategoryParentId", "CategoryChildId", maxCategory); var taskLanguage = new Task(() => { #region JosVirtuemartCategory language engine .MergeLanguage <JosVirtuemartCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCategory>(i => i.VirtuemartCategoryId, "VirtuemartCategoryId", maxCategory); engine .MergeLanguage <JosVirtuemartCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCategory>(i => i.VirtuemartCategoryId, "VirtuemartCategoryId", maxCategory); #endregion #region JosVirtuemartPaymentmethod language engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsEnGb> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsEsE, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsEsE> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsFrFr> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsItIt, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsItIt> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsDeDe, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsDeDe> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsRuRu, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsRuRu> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); #endregion }); taskLanguage.Start(); var taskLanguage2 = new Task(() => { #region JosVirtuemartManufacturer language engine .MergeLanguage <JosVirtuemartManufacturersDeDe, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersDeDe>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersEnGb>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersEsE, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersEsE>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersFrFr>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersItIt, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersItIt>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); #endregion #region JosVirtuemartProduct language engine .MergeLanguage <JosVirtuemartProductsEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartProductsEnGb>(i => i.VirtuemartProductId, "VirtuemartProductId", maxProduct); engine .MergeLanguage <JosVirtuemartProductsFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartProductsFrFr>(i => i.VirtuemartProductId, "VirtuemartProductId", maxProduct); #endregion }); taskLanguage2.Start(); var task1 = new Task(() => { #region merge other type table engine .MergeJoinTable <JosVirtuemartCategoryMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartCategoryMedia>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartCategoryId", Plus = maxCategory }, new Pair { Name = "VirtuemartMediaId", Plus = maxMedia } }); #endregion #region Merge product Join table engine .MergeJoinTable <JosVirtuemartProductCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartProductCategory>( i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "VirtuemartCategoryId", Plus = maxCategory } }); engine .MergeJoinTable <JosVirtuemartProductMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartProductMedia>( i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "VirtuemartMediaId", Plus = maxMedia } }); engine .MergeJoinTable <JosVirtuemartProductPrice, DatabaseTwo.DatabaseTwo.JosVirtuemartProductPrice>(i => i.VirtuemartProductPriceId, "VirtuemartProductPriceId", new[] { new Pair() { Name = "VirtuemartProductId", Plus = maxProduct } }); engine .MergeJoinTable <JosVirtuemartProductRelation, DatabaseTwo.DatabaseTwo.JosVirtuemartProductRelation>(i => i.Id, "Id", new[] { new Pair() { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair() { Name = "RelatedProducts", Plus = maxProduct } }); engine .MergeJoinTable <JosVirtuemartProductCustomfield, DatabaseTwo.DatabaseTwo.JosVirtuemartProductCustomfield>( i => i.VirtuemartCustomfieldId, "VirtuemartCustomfieldId", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "VirtuemartCustomId", Plus = maxCustom } }); #endregion }); task1.Start(); var task3 = new Task(() => { engine .MergeJoinTable <JosVirtuemartCalcCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCalcCategory>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartCalcId", Plus = maxCalc }, new Pair { Name = "VirtuemartCategoryId", Plus = maxCategory } }); engine .MergeJoinTable <JosVirtuemartVendorMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartVendorMedia>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartMediaId", Plus = maxMedia }, }); }); task3.Start(); var taskJUser = new Task <int>(() => { int maxJUser = engine.MergeStatic <JosUser, DatabaseTwo.DatabaseTwo.JosUser>(i => i.Id, null, "Id"); return(maxJUser); }); var taskUser = new Task <int>(() => { int maxUser = engine .MergeJoinTable <JosVirtuemartVmuser, DatabaseTwo.DatabaseTwo.JosVirtuemartVmuser>(i => i.VirtuemartUserId, "VirtuemartUserId", new[] { new Pair { Name = "VirtuemartPaymentmethodId", Plus = maxPaymentMethod } }); return(maxUser); }); taskJUser.Start(); taskUser.Start(); Task.WaitAll(taskUser, taskJUser); int maxUser = taskUser.Result; int maxJUser = taskJUser.Result; var taskuserR = new Task(() => { #region JOS USER engine .MergeJoinTable <JosVirtuemartUserinfo, DatabaseTwo.DatabaseTwo.JosVirtuemartUserinfo>(i => i.VirtuemartUserinfoId, "VirtuemartUserinfoId", new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser } }); engine .MergeJoinTable <JosVirtuemartVmuserShoppergroup, DatabaseTwo.DatabaseTwo.JosVirtuemartVmuserShoppergroup>(i => i.Id, null, new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser }, new Pair { Name = "VirtuemartShoppergroupId", Plus = 0 } }); engine.MergeJoinTable <JosWishlist, DatabaseTwo.DatabaseTwo.JosWishlist>( i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "Userid", Plus = maxJUser } }); engine .MergeJoinTable <JosVirtuemartCart, DatabaseTwo.DatabaseTwo.JosVirtuemartCart >(i => i.VirtuemartCartId, "VirtuemartCartId", new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser } }); engine .MergeJoinTable <JosUserUsergroupMap, DatabaseTwo.DatabaseTwo.JosUserUsergroupMap>(null, null, new[] { new Pair { Name = "UserId", Plus = maxJUser }, new Pair { Name = "GroupId", Plus = 0 }, }); #endregion }); taskuserR.Start(); var orderTask = new Task <int>(() => { int maxOrder = engine .MergeJoinTable <JosVirtuemartOrder, DatabaseTwo.DatabaseTwo.JosVirtuemartOrder>( i => i.VirtuemartOrderId, "VirtuemartOrderId", new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser }, new Pair() { Name = "VirtuemartPaymentmethodId", Plus = maxPaymentMethod } }); return(maxOrder); }); orderTask.Start(); Task.WaitAll(orderTask); var maxOrder = orderTask.Result; var taskOrderR = new Task(() => { #region Order engine .MergeJoinTable <JosVirtuemartOrderUserinfo, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderUserinfo>(i => i.VirtuemartOrderUserinfoId, "VirtuemartOrderUserinfoId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder }, new Pair() { Name = "VirtuemartUserId", Plus = maxUser } }); engine .MergeJoinTable <JosVirtuemartOrderItem, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderItem>(i => i.VirtuemartOrderItemId, "VirtuemartOrderItemId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder }, new Pair { Name = "VirtuemartProductId", Plus = maxProduct } }); engine .MergeJoinTable <JosVirtuemartOrderHistory, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderHistory>(i => i.VirtuemartOrderHistoryId, "VirtuemartOrderHistoryId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine .MergeJoinTable <JosVirtuemartOrderCalcRule, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderCalcRule>(i => i.VirtuemartOrderCalcRuleId, "VirtuemartOrderCalcRuleId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); int maxInvoice = engine .MergeJoinTable <JosVirtuemartInvoice, DatabaseTwo.DatabaseTwo.JosVirtuemartInvoice>(i => i.VirtuemartInvoiceId, "VirtuemartInvoiceId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgAlatakMonetico , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgAlatakMonetico>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgAlatakSip , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgAlatakSip>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgPaypal , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgPaypal>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgStandard , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgStandard>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); #endregion }); taskOrderR.Start(); Task.WaitAll(taskOrderR, taskuserR, task1, task3, taskLanguage, taskLanguage2); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("SUCCESS!"); } }
static void Main(string[] args) { var iMapper = Mapper.GetMapper(); var one = new DatabaseOneContext(); using (var two = new DatabaseTwoContext()) { var jCategories = two.JosCategories.Where(i => i.Id > 1).ToList(); int maxJCategories = one.JosCategories.Max(i => i.Id); jCategories.ForEach(i => { i.Id += maxJCategories; if (i.ParentId != 1) { i.ParentId += maxJCategories; } one.JosCategories.Add(iMapper.Map(i, new JosCategory())); }); one.SaveChanges(); var jContents = two.JosContents.ToList(); int maxContents = one.JosContents.Max(i => i.Id); jContents.ForEach(i => { i.Id += maxContents; i.Catid += maxJCategories; one.JosContents.Add(iMapper.Map(i, new JosContent { Parentid = "", TitleAlias = "", Mask = "", Sectionid = "", })); }); one.SaveChanges(); var engine = new Engine.Engine(one, two, iMapper); var maxCategory = engine .MergeStatic <JosVirtuemartCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCategory>(i => i.VirtuemartCategoryId, "VirtuemartCategoryId"); #region JosVirtuemartCategory language engine .MergeLanguage <JosVirtuemartCategoriesFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartCategoriesFrFr>(i => i.VirtuemartCategoryId, "VirtuemartCategoryId", maxCategory); engine .MergeLanguage <DatabaseOne.DatabaseOne.JosVirtuemartCategoriesEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartCategoriesEnGb>(i => i.VirtuemartCategoryId, "VirtuemartCategoryId", maxCategory); #endregion var maxProduct = engine .MergeRelationSelf <JosVirtuemartProduct, DatabaseTwo.DatabaseTwo.JosVirtuemartProduct>(i => i.VirtuemartProductId, "VirtuemartProductId", "ProductParentId"); #region JosVirtuemartProduct language engine .MergeLanguage <JosVirtuemartProductsEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartProductsEnGb>(i => i.VirtuemartProductId, "VirtuemartProductId", maxProduct); engine .MergeLanguage <JosVirtuemartProductsFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartProductsFrFr>(i => i.VirtuemartProductId, "VirtuemartProductId", maxProduct); Console.WriteLine(maxProduct); #endregion try { int maxCustom = engine .MergeRelationSelf <JosVirtuemartCustom, DatabaseTwo.DatabaseTwo.JosVirtuemartCustom>( i => i.VirtuemartCustomId, "VirtuemartCustomId", "CustomParentId"); var maxManufacture = engine .MergeStatic <JosVirtuemartManufacturer, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturer>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId"); // can run parallel var maxMedia = engine .MergeStatic <JosVirtuemartMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartMedia>(i => i.VirtuemartMediaId, j => j.VirtuemartMediaId > 1, "VirtuemartMediaId"); // run parallel var maxPaymentMethod = engine .MergeStatic <JosVirtuemartPaymentmethod, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethod> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId"); // run parallel engine .MergeJoinSelfTable <JosVirtuemartCategoryCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCategoryCategory>(i => i.Id, "Id", "CategoryParentId", "CategoryChildId", maxCategory); #region JosVirtuemartPaymentmethod language engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsEnGb> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsEsE, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsEsE> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsFrFr> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsItIt, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsItIt> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsDeDe, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsDeDe> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); engine .MergeLanguageSlug <JosVirtuemartPaymentmethodsRuRu, DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentmethodsRuRu> (i => i.VirtuemartPaymentmethodId, "VirtuemartPaymentmethodId", maxPaymentMethod); #endregion #region JosVirtuemartManufacturer language engine .MergeLanguage <JosVirtuemartManufacturersDeDe, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersDeDe>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersEnGb, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersEnGb>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersEsE, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersEsE>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersFrFr, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersFrFr>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); engine .MergeLanguage <JosVirtuemartManufacturersItIt, DatabaseTwo.DatabaseTwo.JosVirtuemartManufacturersItIt>( i => i.VirtuemartManufacturerId, "VirtuemartManufacturerId", maxManufacture); #endregion #region merge other type table engine .MergeJoinTable <JosVirtuemartCategoryMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartCategoryMedia>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartCategoryId", Plus = maxCategory }, new Pair { Name = "VirtuemartMediaId", Plus = maxMedia } }); #endregion #region Merge product Join table engine .MergeJoinTable <JosVirtuemartProductCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartProductCategory>( i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "VirtuemartCategoryId", Plus = maxCategory } }); engine .MergeJoinTable <JosVirtuemartProductMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartProductMedia>( i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "VirtuemartMediaId", Plus = maxMedia } }); engine .MergeJoinTable <JosVirtuemartProductPrice, DatabaseTwo.DatabaseTwo.JosVirtuemartProductPrice>(i => i.VirtuemartProductPriceId, "VirtuemartProductPriceId", new[] { new Pair() { Name = "VirtuemartProductId", Plus = maxProduct } }); engine .MergeJoinTable <JosVirtuemartProductRelation, DatabaseTwo.DatabaseTwo.JosVirtuemartProductRelation>(i => i.Id, "Id", new[] { new Pair() { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair() { Name = "RelatedProducts", Plus = maxProduct } }); engine .MergeJoinTableCustom <JosVirtuemartProductCustomfield, DatabaseTwo.DatabaseTwo.JosVirtuemartProductCustomfield>( i => i.VirtuemartCustomfieldId, "VirtuemartCustomfieldId", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "VirtuemartCustomId", Plus = maxCustom } }, new Pair { Name = "", Plus = maxMedia }, new Pair { Name = "", Plus = maxProduct }); #endregion int maxCalc = engine .MergeStatic <JosVirtuemartCalc, DatabaseTwo.DatabaseTwo.JosVirtuemartCalc>(i => i.VirtuemartCalcId, "VirtuemartCalcId"); engine .MergeJoinTable <JosVirtuemartCalcCategory, DatabaseTwo.DatabaseTwo.JosVirtuemartCalcCategory>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartCalcId", Plus = maxCalc }, new Pair { Name = "VirtuemartCategoryId", Plus = maxCategory } }); #region JOS USER int maxJUser = engine.MergeStatic <JosUser, DatabaseTwo.DatabaseTwo.JosUser>(i => i.Id, (a) => true, "Id"); int maxUser = engine .MergeJoinTable <JosVirtuemartVmuser, DatabaseTwo.DatabaseTwo.JosVirtuemartVmuser>(i => i.VirtuemartUserId, "VirtuemartUserId", new[] { new Pair { Name = "VirtuemartPaymentmethodId", Plus = maxPaymentMethod } }); engine .MergeJoinTableS1 <JosVirtuemartUserinfo, DatabaseTwo.DatabaseTwo.JosVirtuemartUserinfo>(i => i.VirtuemartUserinfoId, "VirtuemartUserinfoId", new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser } }); engine .MergeJoinTable <JosVirtuemartVmuserShoppergroup, DatabaseTwo.DatabaseTwo.JosVirtuemartVmuserShoppergroup>(i => i.Id, null, new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser }, new Pair { Name = "VirtuemartShoppergroupId", Plus = 0 } }); engine.MergeJoinTable <JosWishlist, DatabaseTwo.DatabaseTwo.JosWishlist>( i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartProductId", Plus = maxProduct }, new Pair { Name = "Userid", Plus = maxJUser } }); engine .MergeJoinTable <JosVirtuemartCart, DatabaseTwo.DatabaseTwo.JosVirtuemartCart >(i => i.VirtuemartCartId, "VirtuemartCartId", new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser } }); engine .MergeJoinTable <JosUserUsergroupMap, DatabaseTwo.DatabaseTwo.JosUserUsergroupMap>(null, null, new[] { new Pair { Name = "UserId", Plus = maxJUser }, new Pair { Name = "GroupId", Plus = 0 }, }); #endregion engine .MergeJoinTable <JosVirtuemartVendorMedia, DatabaseTwo.DatabaseTwo.JosVirtuemartVendorMedia>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartMediaId", Plus = maxMedia }, }); #region Order int maxOrder = engine .MergeJoinTable <JosVirtuemartOrder, DatabaseTwo.DatabaseTwo.JosVirtuemartOrder>( i => i.VirtuemartOrderId, "VirtuemartOrderId", new[] { new Pair { Name = "VirtuemartUserId", Plus = maxUser }, new Pair() { Name = "VirtuemartPaymentmethodId", Plus = maxPaymentMethod } }); engine .MergeJoinTable <JosVirtuemartOrderUserinfo, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderUserinfo>(i => i.VirtuemartOrderUserinfoId, "VirtuemartOrderUserinfoId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder }, new Pair() { Name = "VirtuemartUserId", Plus = maxUser } }); engine .MergeJoinTable <JosVirtuemartOrderItem, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderItem>(i => i.VirtuemartOrderItemId, "VirtuemartOrderItemId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder }, new Pair { Name = "VirtuemartProductId", Plus = maxProduct } }); engine .MergeJoinTable <JosVirtuemartOrderHistory, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderHistory>(i => i.VirtuemartOrderHistoryId, "VirtuemartOrderHistoryId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine .MergeJoinTable <JosVirtuemartOrderCalcRule, DatabaseTwo.DatabaseTwo.JosVirtuemartOrderCalcRule>(i => i.VirtuemartOrderCalcRuleId, "VirtuemartOrderCalcRuleId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); int maxInvoice = engine .MergeJoinTable <JosVirtuemartInvoice, DatabaseTwo.DatabaseTwo.JosVirtuemartInvoice>(i => i.VirtuemartInvoiceId, "VirtuemartInvoiceId", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgAlatakMonetico , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgAlatakMonetico>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgAlatakSip , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgAlatakSip>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgPaypal , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgPaypal>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); engine.MergeJoinTable <JosVirtuemartPaymentPlgStandard , DatabaseTwo.DatabaseTwo.JosVirtuemartPaymentPlgStandard>(i => i.Id, "Id", new[] { new Pair { Name = "VirtuemartOrderId", Plus = maxOrder } }); #endregion engine .MergeJoinTableCustom <JosVirtuemartProductCustomPlgIstraxxDownload, DatabaseTwo.DatabaseTwo.JosVirtuemartProductCustomPlgIstraxxDownload>(i => i.Id, "Id", new [] { new Pair { Name = "VirtuemartOrderItemId", Plus = maxOrder } }, new Pair { Name = "", Plus = maxMedia }); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("SUCCESS!"); } }