zzzprojects / Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://bulk-operations.net
142 stars 36 forks source link

An error occured, no primary key could be found or resolved. #46

Closed zhanfuzhi closed 5 years ago

zhanfuzhi commented 5 years ago

在 Z.BulkOperations.BulkOperation.() 在 Z.BulkOperations.BulkOperation.Execute() 在 Z.BulkOperations.BulkOperation.BulkDelete() 在 Z.BulkOperations.BulkOperation1.BulkDelete(List1 datasource) 在 yw56.rec.Tasks.Task01Recs.Task01RecService.<>c__DisplayClass14_0.b__0(Object taskindex) 位置 F:\project\rec\3.9.0\src\yw56.rec.Application\Tasks\Task01Recs\Task01RecService.cs:行号 304

using Abp.Domain.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yw56.rec.SysTasks
{
    [Table("sys_task_history4")]
    public class sysTask:Entity<long>
    {
        [Column("taskId")]
        public override long Id { get => base.Id; set => base.Id = value; }

        public long taskCode { get; set; }

        public int status { get; set; }

        public System.String businessCode { get; set; }
        public int platformCode { get; set; }

        public System.DateTime createTime { get; set; }
        public System.String businessBody { get; set; }

        public System.String businessRemark { get; set; }
    }
}

   using (var connection = new SqlConnection(connectionString))
                        {
                            connection.Open();

                            // BulkInsert
                            using (var bulk = new BulkOperation<sysTask>(connection))
                            {
                                //bulk.DestinationTableName = "Task_01_Rec_History";
                                //bulk.AutoMapOutputDirection = false; // performance can be improved with options

                                //bulk.BulkInsert(tasklist.ToList<Task01Rec>());

                                bulk.DestinationTableName = "sys_task_history4";
                                bulk.BatchSize = 100;
                                bulk.BulkDelete(systasklist.ToList<sysTask>());

                            }
                        }
JonathanMagnan commented 5 years ago

Hello @zhanfuzhi ,

What's the column name of your primary key in your database? Could it be possible the case sensitive is not the same?

zhanfuzhi commented 5 years ago

The ABP framework does not support EF BulkInsert ,Help Me

JonathanMagnan commented 5 years ago

Hello @zhanfuzhi ,

Can you provide a runnable project/solution?

Looking at your code here (https://github.com/zzzprojects/EntityFramework-Extensions/issues/227), it looks to support it. So we probably missing something in your question.