public static void BulkMergeUtil <T>(List <T> list) { using (IDbConnection db = DBConnectionHelper.getConnection()) { db.BulkMerge(list); } }
/* * This method simply merges whatever data is passed to it into DB */ public static void updateURLs(Queue <URL> myUrlQueue) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)){ if (db != null) { db.BulkMerge(myUrlQueue); } } }
/* * This method simply merges whatever data is passed to it into DB */ public static void updateURLs(Queue <URL> myUrlQueue) { String dbConfig = new MyConfigurationHelper().getDBConnectionConfig(); using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)){ if (db != null) { db.BulkMerge(myUrlQueue); } } }
//insert reviews in db public static void insertParsedReviews(List <Review> reviewsList) { if (reviewsList == null) { return; } if (reviewsList != null && reviewsList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)){//get connection db.BulkMerge(reviewsList); } } }
public static void insertParsedApartmentList(List <Apartments> apartments) { if (apartments == null) { return; } if (apartments != null && apartments.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)) {//get connection db.BulkMerge(apartments); } } }
public static void insertParsedNTPI(List <NTPI> NtpiList) { if (NtpiList == null) { return; } if (NtpiList != null && NtpiList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)) {//get connection db.BulkMerge(NtpiList); } } }
public static void insertParsedSchools(List <School> schoolsList) { if (schoolsList == null) { return; } if (schoolsList != null && schoolsList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)) {//get connection db.BulkMerge(schoolsList); } } }
public static void insertParsedPropertyAmenities(List <Amenitytype> amenityTypeList) { if (amenityTypeList == null) { return; } if (amenityTypeList != null && amenityTypeList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)) {//get connection db.BulkMerge(amenityTypeList) .ThenForEach(x => x.amenityList .ForEach(y => y.amenitytype = x.id)) .ThenBulkMerge(x => x.amenityList); } } }
public static void insertParsedExpenseType(List <Expensetype> expensesTypeList) { if (expensesTypeList == null) { return; } if (expensesTypeList != null && expensesTypeList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection(dbConfig)){ //get connection db.BulkMerge(expensesTypeList) //insert the list of property types .ThenForEach(x => x.expensesList .ForEach(y => y.expensetype = x.id)) //set property type id for properties .ThenBulkMerge(x => x.expensesList); } } }
public static void insertParsedSchools(List <School> schoolsList) { if (schoolsList == null) { return; } if (schoolsList != null && schoolsList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection()) {//get connection schoolsList.ForEach(x => x.id = getSchoolIdDb(x)); db.BulkMerge(schoolsList) .ThenForEach(x => x.PropSchoolMapping .ForEach(y => y.School = x.id)) .ThenBulkMerge(x => x.PropSchoolMapping); } } }
public static void insertParsedNTPI(List <NTPICategory> NtpiCategoryList) { if (NtpiCategoryList == null) { return; } if (NtpiCategoryList != null && NtpiCategoryList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection()) {//get connection NtpiCategoryList.ForEach(x => x.Id = getNtpiCategoryIdDb(x)); db.BulkMerge(NtpiCategoryList) .ThenForEach(x => x.NtpiList.ForEach(y => y.NTPC = x.Id)) .ThenBulkMerge(x => x.NtpiList) .ThenForEach(y => y.PropNTPIMapping.ForEach(z => z.NPTI = y.id)) .ThenBulkMerge(y => y.PropNTPIMapping); } } }
/* * Method to insert parsed properties into DB */ public void insertParsedProperties(PropertyData propData) { if (propData == null) { return; } List <PropertyType> propertyTypeList = propData.urlList; if (propertyTypeList != null && propertyTypeList.Count > 0) { using (IDbConnection db = DBConnectionHelper.getConnection()){ //get connection db.BulkMerge(propertyTypeList) //insert the list of property types .ThenForEach(x => x.properties .ForEach(y => y.propertytype = x.id)) //set property type id for properties .ThenBulkMerge(x => x.properties) //insert properties .ThenForEach(x => x.url.property = x.id) //set property id for urls .ThenBulkMerge(x => x.url); //insert urls } } }
/// <summary> /// An IDbConnection extension method to MERGE (Upsert) entities in a database table or a view. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="connection">The connection to act on.</param> /// <param name="items">items to merge.</param> /// <param name="selectors">The selection of entities to merge.</param> /// <returns>A DapperPlusActionSet<T></returns> public static DapperPlusActionSet <T> BulkMerge <T>(this IDbConnection connection, IEnumerable <T> items, params Func <T, object>[] selectors) { return(connection.BulkMerge(null, items, selectors)); }
/// <summary> /// An IDbConnection extension method to MERGE (Upsert) entities in a database table or a view. /// </summary> /// <typeparam name="T">Generic type parameter.</typeparam> /// <param name="connection">The connection to act on.</param> /// <param name="items">items to merge.</param> /// <returns>A DapperPlusActionSet<T></returns> public static DapperPlusActionSet <T> BulkMerge <T>(this IDbConnection connection, params T[] items) { return(connection.BulkMerge <T>(null, items)); }