profile
viewpoint

gandhis1/mbs-analytics 4

Cash flow and analytics engine for mortgage-backed securities (MBS)

gandhis1/acuity_schedule 0

Creates a schedule and tracks earnings based on appointments on Acuity

gandhis1/core 0

Home repository for .NET Core

gandhis1/CsvHelper 0

Library to help reading and writing CSV files

gandhis1/EFCore.BulkExtensions 0

Entity Framework Core Bulk Batch Extensions for Insert Update Delete and Read (CRUD) operations on SQL Server and SQLite

gandhis1/pandas 0

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more

gandhis1/parso 0

A Python Parser Written in Python [Not Released, Yet]

gandhis1/pythonVSCode 0

Cross platform editing, debugging, linting, testing (and more) Python (2.7 to 3.6) code (including Jupyter support) using Visual Studio Code

gandhis1/scipy 0

Scipy library main repository

gandhis1/test-repository 0

Various scripts and miscellaneous code

Pull request review commentborisdj/EFCore.BulkExtensions

Fix when primary key is not "int" or "long". Fixes #380

 public static async Task MergeAsync(DbContext context, Type type, IList<object>                             command.CommandText = SqlQueryBuilderSqlite.SelectLastInsertRowId();                             long lastRowIdScalar = (long)await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false);                             var identityPropertyInteger = false;+                            var identityPropertyUnsigned = false;+                            var identityPropertyByte = false;+                            var identityPropertyShort = false;                             var accessor = TypeAccessor.Create(type, true);                             string identityPropertyName = tableInfo.PropertyColumnNamesDict.SingleOrDefault(a => a.Value == tableInfo.IdentityColumnName).Key;-                            if (accessor.GetMembers().FirstOrDefault(x => x.Name == identityPropertyName)?.Type == typeof(int))+                            if (accessor.GetMembers().FirstOrDefault(x => x.Name == identityPropertyName)?.Type == typeof(ulong))

You have ulong, do you need to check long as well?

claunia

comment created time in 20 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentdotnet/sdk

dotnet publish won't publish self contained exe without a RuntimeIdentifier. I am passing -r in the command.

This error is kind of silly. If you just drop the --self-contained then it works. I can't see a rational reason why having it - although it is redundant - should cause this to fail.

ajmcateer

comment created time in a month

Pull request review commentborisdj/EFCore.BulkExtensions

Various small fixes including warnings, code styles and spellings

 public enum DbServer     {         SqlServer,         MySql,-        PostrgeSql,+        Npgsql,

Not sure if a .NET specific library is the best name here - everything else is the generic name of the database. That said it was mis-spelled previously, should have "PostgreSQL"

Is this enumeration element even used yet, anyway?

TheCactusBlue

comment created time in a month

PullRequestReviewEvent

Pull request review commentborisdj/EFCore.BulkExtensions

Various small fixes including warnings, code styles and spellings

  namespace EFCore.BulkExtensions {+    // public class BatchSql+    // {+    //     public string Sql;+    //     public string TableAlias;+    //     public string TableAliasSufixAs;+    //     public string TopStatement;+    //     public string LeadingComments;+    //     public IEnumerable<object> InnerParameters;+    // }+    

Is this intended to be commented out? Why is it here?

TheCactusBlue

comment created time in a month

PullRequestReviewEvent

Pull request review commentborisdj/EFCore.BulkExtensions

Various small fixes including warnings, code styles and spellings

 internal static SqliteCommand GetSqliteCommand<T>(DbContext context, Type type,             SqliteCommand command = connection.CreateCommand();             command.Transaction = transaction; -            OperationType operationType = tableInfo.BulkConfig.OperationType;+            var operationType = tableInfo.BulkConfig.OperationType; -            if (operationType == OperationType.Insert)+            switch (operationType)             {-                command.CommandText = SqlQueryBuilderSqlite.InsertIntoTable(tableInfo, OperationType.Insert);-            }-            else if (operationType == OperationType.InsertOrUpdate)-            {-                command.CommandText = SqlQueryBuilderSqlite.InsertIntoTable(tableInfo, OperationType.InsertOrUpdate);-            }-            else if (operationType == OperationType.InsertOrUpdateDelete)-            {-                throw new NotSupportedException("Sqlite supports only UPSERT(analog for MERGE WHEN MATCHED) but does not have functionality to do: 'WHEN NOT MATCHED BY SOURCE THEN DELETE'" +-                                                "What can be done is to read all Data, find rows that are not is input List, then with those do the BulkDelete.");-            }-            else if (operationType == OperationType.Update)-            {-                command.CommandText = SqlQueryBuilderSqlite.UpdateSetTable(tableInfo);-            }-            else if (operationType == OperationType.Delete)-            {-                command.CommandText = SqlQueryBuilderSqlite.DeleteFromTable(tableInfo);+                case OperationType.Insert:+                    command.CommandText = SqlQueryBuilderSqlite.InsertIntoTable(tableInfo, OperationType.Insert);+                    break;+                case OperationType.InsertOrUpdate:+                    command.CommandText = SqlQueryBuilderSqlite.InsertIntoTable(tableInfo, OperationType.InsertOrUpdate);+                    break;+                case OperationType.InsertOrUpdateDelete:+                    throw new NotSupportedException("Sqlite supports only UPSERT(analog for MERGE WHEN MATCHED) but does not have functionality to do: 'WHEN NOT MATCHED BY SOURCE THEN DELETE'" ++                                                    "What can be done is to read all Data, find rows that are not is input List, then with those do the BulkDelete.");+                case OperationType.Update:+                    command.CommandText = SqlQueryBuilderSqlite.UpdateSetTable(tableInfo);+                    break;+                case OperationType.Delete:+                    command.CommandText = SqlQueryBuilderSqlite.DeleteFromTable(tableInfo);+                    break;

Can you use the C# 8.0 switch expression syntax here? I think it would be even cleaner. The exception state could be done in an if statement prior to the switch expression

TheCactusBlue

comment created time in a month

issue commentExcelDataReader/ExcelDataReader

XLSB support not in latest Nuget package

Thanks! I upgraded and tested it out on some of the typical XLSB files I have. Appears to work no issues.

spetersn

comment created time in 2 months

issue openedcapitalone/datacompy

Use deterministic output order for column-based reporting

One section of the output report is called "Sample Rows with Unequal Values". It prints each column with differences and then 10 rows of differences. However, I've noticed that this output changes with multiple runs - so multiple calls of .report() will give you output in a different order. As an example, if you have two dataframes with the columns A, B, and C, all of which have differences, then one run may give you results in the order of B, C, A, the second in C, A, B, etc.

This isn't a huge issue - it's just cosmetic. But I do think the output would be cleaner if it the ordering was deterministic. Moreover, it should probably match the ordering of the columns of the first dataframe, which is referred to as df1 in the code.

This section of the report is generated by looping through self.column_stats and generated sample rows of differences. self.column_stats is generated from the method _intersect_compare(), which loops through self.intersect_columns(). And finally, the issue is in self.interesect_columns(), which uses set - an unordered data structure - and does an intersection.

https://github.com/capitalone/datacompy/blob/8d96429c9cf574f8d448a4e63301f0025ad467ee/datacompy/core.py#L212-L214

I'm thinking the solution to this problem is use an ordered set. There are packages available on PyPi for this.

created time in 2 months

issue commentExcelDataReader/ExcelDataReader

XLSB support not in latest Nuget package

@andersnm @appel1 Any update on this? Would really appreciate it as this would be a highly useful feature for me

spetersn

comment created time in 2 months

issue commentcapitalone/datacompy

Allow customization of comparison report

Closing, I found out this already exists as well.

gandhis1

comment created time in 2 months

issue closedcapitalone/datacompy

Allow customization of comparison report

At present it does not seem the built-in comparison report accepts any parameters. For one, I would like to be able to set the row limit myself as far as how many differences are printed per field. By default this is 10 - I'd like to optionally change this.

Appreciate the use of smart defaults, but any hard-coded parameter - 10 or otherwise, I feel ought to be something that can be configured externally.

closed time in 2 months

gandhis1

issue closedcapitalone/datacompy

Make lowercasing of column names optional

If you are using camel case naming conventions and have several multi-word column names, then automatic lowercasing of names will make the final result less readable.

There is only a need to lowercase when you have case-insensitive duplicates. If you do not, there is no need to disambiguate. So why not add an option to turn this off? If there are duplicates, then simply throw - it already does this, anyhow.

closed time in 2 months

gandhis1

issue commentcapitalone/datacompy

Make lowercasing of column names optional

Ah I see this was added very recently. In fact, the version on PyPi (0.70) doesn't even contain this feature yet, which is why I hadn't noticed it. This can be closed, although I hope you guys will be able to release the new version to PyPi soon?

gandhis1

comment created time in 2 months

issue openedcapitalone/datacompy

Allow customization of comparison report

At present it does not seem the built-in comparison report accepts any parameters. For one, I would like to be able to set the row limit myself as far as how many differences are printed per field. By default this is 10 - I'd like to optionally change this.

Appreciate the use of smart defaults, but any hard-coded parameter - 10 or otherwise, I feel ought to be something that can be configured externally.

created time in 3 months

issue openedcapitalone/datacompy

Make lowercasing of column names optional

If you are using camel case naming conventions and have several multi-word column names, then automatic lowercasing of names will make the final result less readable.

There is only a need to lowercase when you have case-insensitive duplicates. If you do not, there is no need to disambiguate. So why not add an option to turn this off? If there are duplicates, then simply throw - it already does this, anyhow.

created time in 3 months

issue commentborisdj/EFCore.BulkExtensions

Support bulk operations extension methods on DbSet instead of just DbContext

Sorry, I don't really mean the naming of the methods - I mean that because BulkInsert() is available on DbContext it should be available on DbSet as well. This makes the bulk operations consistent with the standard EF operations which can be invoked on either object.

So I should be able to do:

dbContext.BulkInsert(entities);
dbContext.BulkDelete(entities);

As well as:

dbContext.SomeTable.BulkInsert(entities);
dbContext.SomeTable.BulkDelete(entities);

Would you accept a PR to add this interface?

gandhis1

comment created time in 3 months

issue commentborisdj/EFCore.BulkExtensions

BulkInsert Failed to attempt to insert with custom column name

@gustavopinho - Is your EF core model valid? If you have a foreign key against a JobFunctions table, you need a navigation element of type JobFunction with a [ForeignKey(nameof(JobFunctionId))] attribute, and an int JobFunction property with a [ForeignKey(nameof(JobFunction))] attribute.

Correct me if I'm wrong, but what you have now is basically attempting to map a JobFunction navigation element to JobFunctionId using the Column attribute (which is the attribute for a one-to-one column rename).

Specifically, this is what you have:

[Column("JobFunctionID")]
public JobFunction JobFunction { get; set; }
[Column("StatusID")]
public Status Status { get; set; }
[Column("EmployeeID")]
public Employee Employee { get; set; }

For a proper foreign key relationship, this is what you are supposed to have. Technically I believe you don't need the attribute on both the navigation element and the foreign key itself, but for demonstration's sake:

[ForeignKey("JobFunction")]
public int JobFunctionID { get; set; }
[ForeignKey("Status")]
public int StatusID { get; set; }
[ForeignKey("Employee")]
public int EmployeeID { get; set; }
[ForeignKey("JobFunctionID")]
public JobFunction JobFunction { get; set; }
[ForeignKey("StatusID")]
public Status Status { get; set; }
[ForeignKey("EmployeeID")]
public Employee Employee { get; set; }
gustavopinho

comment created time in 3 months

issue openedborisdj/EFCore.BulkExtensions

Support bulk operations extension methods on DbSet instead of just DbContext

The standard EF Core AddRange() and RemoveRange() methods are available on either the DbSet or DbContext classes. Is there a compelling reason to not offer both interfaces for bulk operations as well?

created time in 3 months

starteddotnet/coreclr

started time in 3 months

issue commentborisdj/EFCore.BulkExtensions

BulkInsert Failed to attempt to insert with custom column name

What version of the library are you using? If you revert to version 3.1.1, does it work?

I think it's important to confirm that this isn't a regression that occurred between version 3.1.2 to the current 3.1.4, as these all were released in the past week.

gustavopinho

comment created time in 3 months

issue commentborisdj/EFCore.BulkExtensions

BulkInsert Failed to attempt to insert with custom column name

When you replace the BulkInsert() call with an AddRange() and SaveChanges(), does it work?

gustavopinho

comment created time in 3 months

startedborisdj/EFCore.BulkExtensions

started time in 3 months

issue commentmorelinq/MoreLINQ

Ease usage in next major version by renaming methods conflicting with Enumerable methods

Add me to this "horde". I concur with others who believe that using static is not a long-term solution. Deprecation and/or disambiguation is.

voxoid0

comment created time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Use ambient SqliteTransaction if available

 private static void Insert<T>(DbContext context, Type type, IList<T> entities, T                  try                 {-                    var transaction = tableInfo.BulkConfig.SqliteTransaction ?? connection.BeginTransaction();-                    try-                    {-                        var command = GetSqliteCommand(context, type, entities, tableInfo, connection, transaction);+                    var transaction = tableInfo.BulkConfig.SqliteTransaction ?? (SqliteTransaction)context.Database.CurrentTransaction.GetUnderlyingTransaction(tableInfo.BulkConfig); -                        type = tableInfo.HasAbstractList ? entities[0].GetType() : type;-                        var typeAccessor = TypeAccessor.Create(type, true);-                        int rowsCopied = 0;-                        foreach (var item in entities)-                        {-                            LoadSqliteValues(tableInfo, typeAccessor, item, command);-                            command.ExecuteNonQuery();-                            SetProgress(ref rowsCopied, entities.Count, tableInfo.BulkConfig, progress);-                        }-                    }-                    finally+                    var command = GetSqliteCommand(context, type, entities, tableInfo, connection, transaction);++                    type = tableInfo.HasAbstractList ? entities[0].GetType() : type;+                    var typeAccessor = TypeAccessor.Create(type, true);+                    int rowsCopied = 0;+                    foreach (var item in entities)                     {-                        if (tableInfo.BulkConfig.SqliteTransaction == null)-                        {-                            transaction.Commit();-                            transaction.Dispose();-                        }

And the commit code, along with the entire try-finally block, was removed. Nothing else changed, GitHub is just showing indentation changes.

gandhis1

comment created time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Use ambient SqliteTransaction if available

 private static void Insert<T>(DbContext context, Type type, IList<T> entities, T                  try                 {-                    var transaction = tableInfo.BulkConfig.SqliteTransaction ?? connection.BeginTransaction();-                    try-                    {-                        var command = GetSqliteCommand(context, type, entities, tableInfo, connection, transaction);+                    var transaction = tableInfo.BulkConfig.SqliteTransaction ?? (SqliteTransaction)context.Database.CurrentTransaction.GetUnderlyingTransaction(tableInfo.BulkConfig);

In each of the 4 Sqlite operations, this line has changed to use the ambient transaction.

gandhis1

comment created time in 3 months

push eventgandhis1/EFCore.BulkExtensions

Siddhartha Gandhi

commit sha 2aa4c4dd658e156c4f545731e02a2f4c021451b0

Fix NullReferenceException on bulk operations on entities with no keys

view details

Siddhartha Gandhi

commit sha 0f989fc58194ca4496169bbae94e2c9b82b2186a

Only remove identity column from column list if one exists Failure to check for HasIdentity on an entity would lead to NullReferenceException when indexing tableInfo.PropertyColumnNamesDict with tableInfo.IdentityColumnName

view details

Siddhartha Gandhi

commit sha 51135d6d235d22e8cb02c325429e34a903013b64

Fix typo of 'derived' for variable name

view details

Siddhartha Gandhi

commit sha 5e9f5a4321e22ddde334af95e56aa34bcb57b04f

Handle Sqlite operations on derived covariant types If you are running a BulkInsert from a method which accepts AbstractBaseClass, and pass in a set of entities which are DerivedClass, SQL server operations correctly use the derived class entity configuration (ToTable, etc.). However when using Sqlite, it attempts to use the properties of the base class in the type accessor, which will not work if you have extra properties on your derived class.

view details

Boris Djurdjevic

commit sha 977072179e85f6b4e4add7e75048a382ab5378e8

Merge pull request #355 from gandhis1/fix_hasnokey_insert Fix NullReferenceException on bulk operations on entities with no keys

view details

Siddhartha Gandhi

commit sha d23a0996b025adca3f088d4a412fdd18dc2caaf0

Use ambient SqliteTransaction if available Also remove code relating to the creation of a new nested transaction and the committing of said transaction

view details

push time in 3 months

PR opened borisdj/EFCore.BulkExtensions

Use ambient SqliteTransaction if available

Fixes https://github.com/borisdj/EFCore.BulkExtensions/issues/356. Tagging everyone who has touched this code before @borisdj @PawelGerr

This is a fundamental change so it definitely requires some review/discussion prior to merge. The diff looks like a lot but this is merely indentation changes - I will annotate the exact lines which have actually changed.

In summary - SQL Server supports the following code out of the box, and as far as I can tell, does NOT use a nested transaction to do this:

using var transaction = dbContext.Database.BeginTransactionAsync();
dbContext.BulkInsert(entities);
transaction.Commit();

This code does NOT work out of the box with Sqlite. This is because you need to explicitly specify the SqliteTransaction (conversely SqliteConnection is unnecessary). I cannot fathom why this should be required, but the reason it is, is because the Sqlite implementation chooses to create a new transaction and then commit it, and Sqlite does not support nested transactions.

The code here removes the nested transaction, and always uses the ambient transaction. I would even argue as far as deprecating the SqliteConnection and SqliteTransaction parameters. Unless I'm missing something, I just don't understand what the need is for these when using Sqlite and why this need does not exist when using SQL Server.

Perhaps I lack a full understanding of the rationale behind these features, as all I can see from my vantage point is two implementations that are inconsistent, and therefore require that application code be "smart" and aware of the db context provider. The whole point of Entity Framework is that application code should be decoupled from the provider, so I think it would be optimal to be able to switch out Sqlite and SQL Server with no change in application code.

+74 -114

0 comment

1 changed file

pr created time in 3 months

create barnchgandhis1/EFCore.BulkExtensions

branch : sqlite_transaction

created branch time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Fix NullReferenceException on bulk operations on entities with no keys

 private void LoadData<T>(DbContext context, Type type, IList<T> entities, bool l             if (entityType.IsAbstract())             {                 var extendedAllProperties = allProperties.ToList();-                foreach (var dervied in entityType.GetDirectlyDerivedTypes())+                foreach (var derived in entityType.GetDirectlyDerivedTypes())                 {-                    extendedAllProperties.AddRange(dervied.GetProperties());+                    extendedAllProperties.AddRange(derived.GetProperties());

Merely fixing a typo.

gandhis1

comment created time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Fix NullReferenceException on bulk operations on entities with no keys

 private void LoadData<T>(DbContext context, Type type, IList<T> entities, bool l             bool AreSpecifiedUpdateByProperties = BulkConfig.UpdateByProperties?.Count() > 0;             var primaryKeys = entityType.FindPrimaryKey()?.Properties?.Select(a => a.Name)?.ToList(); -            HasSinglePrimaryKey = primaryKeys.Count == 1;+            HasSinglePrimaryKey = primaryKeys?.Count == 1;

The previous updates fixed line 124 with conditional null access, but this line, which is also susceptible to a potential null value on HasNoKey() entities, was omitted. This is fixed here.

gandhis1

comment created time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Fix NullReferenceException on bulk operations on entities with no keys

 public static string InsertIntoTable(TableInfo tableInfo, OperationType operatio             List<string> columnsList = tableInfo.PropertyColumnNamesDict.Values.ToList();              bool keepIdentity = tableInfo.BulkConfig.SqlBulkCopyOptions.HasFlag(SqlBulkCopyOptions.KeepIdentity);-            if(operationType == OperationType.Insert && !keepIdentity)+            if(operationType == OperationType.Insert && !keepIdentity && tableInfo.HasIdentity)

In the absence of this check, on line 22, tableInfo.IdentityColumnName will be null, leading to a NullReferenceException when indexing tableInfo.PropertyColumnNamesDict.

gandhis1

comment created time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Fix NullReferenceException on bulk operations on entities with no keys

 public static async Task MergeAsync(DbContext context, Type type, IList<object>                     {                         var command = GetSqliteCommand(context, type, entities, tableInfo, connection, transaction); +                        type = tableInfo.HasAbstractList ? entities[0].GetType() : type;

The type that is passed in is always the abstract base class if the entity being passed in is covariant. So for instance BulkInsert<T> at compile time recognizes T as AbstractBaseClass, but at run time you may be passing in a type of DerivedClass.

gandhis1

comment created time in 3 months

issue openedborisdj/EFCore.BulkExtensions

SQL Sever implementations use the existing transaction while Sqlite does not

@borisdj

In all of the SQL Server operations, the ambient transaction will be used. For example:

https://github.com/borisdj/EFCore.BulkExtensions/blob/1d24af75300eb053a19cf4c2487172d94dc7cf09/EFCore.BulkExtensions/SqlBulkOperation.cs#L60-L66

However in the Sqlite branches, if a Sqlitetransaction is not specified, a new one is created:

https://github.com/borisdj/EFCore.BulkExtensions/blob/1d24af75300eb053a19cf4c2487172d94dc7cf09/EFCore.BulkExtensions/SqlBulkOperation.cs#L112-L119

  1. Why doesn't it use the existing transaction? This would be the following line of code:

var transaction = (SqliteTransaction)dbContext.Databse.CurrentTransaction.GetUnderlyingTransaction()

  1. If, per 1 above, it can sniff out the ambient SqliteTransaction, under what circumstances are the config parameters needed?

  2. Sqlite notoriously cannot handle nested transactions, so if you are mocking a SQL Server connection with a Sqlite in-memory database, which I believe will be a very common application, and you wrap your bulk operations in a DbContext transaction, then you will hit this issue and will have to make your code aware of the Db provider. Which totally undermines the whole point of entity framework, in that the db context is dependency injected so your code does not need to be intelligent / coupled.

created time in 3 months

push eventgandhis1/EFCore.BulkExtensions

Siddhartha Gandhi

commit sha 5e9f5a4321e22ddde334af95e56aa34bcb57b04f

Handle Sqlite operations on derived covariant types If you are running a BulkInsert from a method which accepts AbstractBaseClass, and pass in a set of entities which are DerivedClass, SQL server operations correctly use the derived class entity configuration (ToTable, etc.). However when using Sqlite, it attempts to use the properties of the base class in the type accessor, which will not work if you have extra properties on your derived class.

view details

push time in 3 months

push eventgandhis1/EFCore.BulkExtensions

Siddhartha Gandhi

commit sha 51135d6d235d22e8cb02c325429e34a903013b64

Fix typo of 'derived' for variable name

view details

push time in 3 months

pull request commentborisdj/EFCore.BulkExtensions

Fix NullReferenceException on bulk operations on entities with no keys

@knalinne I also included a fix for entities which do not have an identity column going through an irrelevant branch in SqlQueryBuilderSqlite.cs.

gandhis1

comment created time in 3 months

push eventgandhis1/EFCore.BulkExtensions

Siddhartha Gandhi

commit sha 0f989fc58194ca4496169bbae94e2c9b82b2186a

Only remove identity column from column list if one exists Failure to check for HasIdentity on an entity would lead to NullReferenceException when indexing tableInfo.PropertyColumnNamesDict with tableInfo.IdentityColumnName

view details

push time in 3 months

Pull request review commentborisdj/EFCore.BulkExtensions

Fix query generation with auto identity

 public static string InsertIntoTable(TableInfo tableInfo, OperationType operatio             bool keepIdentity = tableInfo.BulkConfig.SqlBulkCopyOptions.HasFlag(SqlBulkCopyOptions.KeepIdentity);             if(operationType == OperationType.Insert && !keepIdentity)             {-                columnsList = columnsList.Where(a => a != tableInfo.IdentityColumnName).ToList();+                var identityColumnName = tableInfo.PropertyColumnNamesDict[tableInfo.IdentityColumnName];+                columnsList = columnsList.Where(a => a != identityColumnName).ToList();

@knalinne If the table does not have an identity column - i.e. tableInfo.IdentityColumnName == null, this change leads to a NullReferenceException. I am submitting an update for this that checks for tableInfo.HasIdentity in the if statement here.

knalinne

comment created time in 3 months

PR opened borisdj/EFCore.BulkExtensions

Fix NullReferenceException on bulk operations on entities with no keys

@borisdj

I tested this with an InsertAsync operation on an entity that was configured with HasNoKey(). It appears to work successfully. That said, I don't know the full context of this code, but it seems in line with the recent changes made in 121d2d5.

+1 -1

0 comment

1 changed file

pr created time in 3 months

create barnchgandhis1/EFCore.BulkExtensions

branch : fix_hasnokey_insert

created branch time in 3 months

fork gandhis1/EFCore.BulkExtensions

Entity Framework Core Bulk Batch Extensions for Insert Update Delete and Read (CRUD) operations on SQL Server and SQLite

fork in 3 months

issue commentborisdj/EFCore.BulkExtensions

No chance to configure BulkInsert for use with HasNoKey entities

Now I get a null reference exception, which was the original behavior. Do I need UpdateByProperties or some special bulk config? Ideally that wouldn't be the case, I ought to be able to insert arbitrary records, regardless of the presence of a uniquely-identifying key.

I finally downloaded the source, debugging it at the moment to pinpoint what the issue is...

guffy1234

comment created time in 3 months

issue commentborisdj/EFCore.BulkExtensions

No chance to configure BulkInsert for use with HasNoKey entities

I'm supposed to be able to BulkInsert on HasNoKey() entities right? I just tested it out, confirmed I am on 3.1.2, and it is still not working for me. Here is the stack trace:


---> System.InvalidOperationException: EntitySet for Type: X must contain a Primary Key
   at EFCore.BulkExtensions.TableInfo.LoadData[T](DbContext context, Type type, IList`1 entities, Boolean loadOnlyPKColumn)
   at EFCore.BulkExtensions.TableInfo.CreateInstance[T](DbContext context, Type type, IList`1 entities, OperationType operationType, BulkConfig bulkConfig)
   at EFCore.BulkExtensions.TableInfo.CreateInstance[T](DbContext context, IList`1 entities, OperationType operationType, BulkConfig bulkConfig)
   at EFCore.BulkExtensions.DbContextBulkTransaction.ExecuteAsync[T](DbContext context, IList`1 entities, OperationType operationType, BulkConfig bulkConfig, Action`1 progress, CancellationToken cancellationToken)
   at EFCore.BulkExtensions.DbContextBulkExtensions.BulkInsertAsync[T](DbContext context, IList`1 entities, BulkConfig bulkConfig, Action`1 progress, CancellationToken cancellationToken)

For what it's worth, looks like @stevekirks made a change recently to add an explicit check in e747a66.

guffy1234

comment created time in 3 months

more