You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an entity with some Guid, int, string, decimal and bool fields.
If I insert 2 sample entites one by one it is working without any problem.
If I insert same entites with BulkCopy - System.Data.SqlServerCe.SqlCeException is thrown.
Exception message:
System.Data.SqlServerCe.SqlCeException: 'Expression evaluation caused an overflow. [ Name of function (if known) = ]'
Stack trace:
System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
LinqToDB.Data.DataConnection.ExecuteNonQuery(DbCommand command)
LinqToDB.Data.DataConnection.ExecuteNonQuery()
Steps to reproduce
Create .Net Framework 4.7.2 console application
Reference linq2db.SqlCe nuget (I used latest version 5.4.0)
Copy sample code below to Program.cs
Copy empty database to application output directory - entities.zip
Run application - get an exception
using LinqToDB.Data;using LinqToDB.Mapping;using LinqToDB;using System;using System.Collections.Generic;namespaceConsoleApp1{[Table(Name ="ProductsContainers")]internalsealedclassProductsContainer{publicProductsContainer(GuidproductId,intcontainerNumber,stringname,decimalweight,decimalamount,decimalgross,boolisDefault){ProductId=productId;ContainerNumber=containerNumber;Name=name;Weight=weight;Amount=amount;Gross=gross;IsDefault=isDefault;}[Column(CanBeNull =false)]publicGuidProductId{get;set;}[Column(CanBeNull =false)]publicintContainerNumber{get;set;}[Column(CanBeNull =false)]publicstringName{get;set;}[Column(CanBeNull =false)]publicdecimalWeight{get;set;}[Column(CanBeNull =false)]publicdecimalAmount{get;set;}[Column(CanBeNull =false)]publicdecimalGross{get;set;}[Column(CanBeNull =false)]publicboolIsDefault{get;set;}}publicclassMyDb:DataConnection{publicMyDb(DataOptions<MyDb>options):base(options.Options){}}internalclassProgram{staticvoidMain(string[]args){varoptions=newDataOptions<MyDb>(new DataOptions().UseSqlCe(@"Data Source=entities.sdf"));using(vardb=new MyDb(options)){varitems=newList<ProductsContainer>(){new ProductsContainer(Guid.NewGuid(),1,"Pack",0,20,0,true),new ProductsContainer(Guid.NewGuid(),1,"Bottle, 0,5",0.08m,0.5m,0.54m,true)};//single insert is working correctly//foreach (var item in items)//{// db.Insert(item);//}//bulk insert throws an exception
db.GetTable<ProductsContainer>().BulkCopy(items);}}}}
Another case of bad type inference by SqlCe, it cannot narrow column type to decimal from integer + decimal value properly.
As workaround you can set decimal part to decimal value:
new ProductsContainer(Guid.NewGuid(),1,"Pack",0.0m,20.0m,0.0m,true),
Describe your issue
I have an entity with some Guid, int, string, decimal and bool fields.
If I insert 2 sample entites one by one it is working without any problem.
If I insert same entites with BulkCopy - System.Data.SqlServerCe.SqlCeException is thrown.
Steps to reproduce
Generated SQL:
Environment details
Linq To DB
version: 5.4.0Database (with version): SQL Server Compact 4.0
ADO.NET Provider (with version): linq2db.SqlCe 5.4.0
Operating system: Windows 10 22H2
.NET Version: .Net Framework 4.7.2
The text was updated successfully, but these errors were encountered: