Comments (9)
Hi @xavave, thanks for noticing that one.
Unfortunately, the SimpleCollectionColumnDataExtractor
creates a new instance of the collection type inside of it. So in this case, it would try to create an insurance of ICollection<TCollectionItem>
, that is why you see that error.
I'm not on my computer at the moment, I'll try to give a look into it tomorrow on how else this can be done. If you have any suggestions, feel free to share as well.
from epplus.dataextractor.
I've added a constructor with ObservableCollection, it should fit my requirements
from epplus.dataextractor.
Awesome ! Thank you !
I will take a look at your code to understand how you have made it
from epplus.dataextractor.
You're welcome! Just released version 2.1.0 on Nuget with this feature
from epplus.dataextractor.
Hi Israel,
Can I use an observable Collection with this new implementation ?
I get an error :
public virtual ObservableCollection<Ingredient> FormulaIngredients { get => formulaIngredients; set => Set(ref formulaIngredients, value); }
error :
'Expression of type 'System.Collections.ObjectModel.Collection1[Formula.DAL.Model.Ingredient]' cannot be used for assignment to type 'System.Collections.ObjectModel.ObservableCollection
1[Formula.DAL.Model.Ingredient]''
and
.WithCollectionProperty(p => p.FormulaIngredients,
1, "F", cfg => cfg
.WithProperty(ing => ing.TempImportId, "RM ID")
.WithProperty(ing => ing.MainTypeId, "RM type", FnConvertMainTypeName)
.WithProperty(ing => ing.Weight, "RM poids", fnParseDouble)
)
from epplus.dataextractor.
Could you check if your formulaIngredients
is null?
If it is null, since ObservableCollection inherits from Collection, the overload used in the WithCollectionProperty
is the Collection one and then the code tries to create a new instance of Collection and assign it to your property...
from epplus.dataextractor.
Nevermind, I was able to reproduce the issue, it is not related to the property being initialized or not. I should publish a fix by tomorrow.
from epplus.dataextractor.
Thanks for noticing that error @xavave. Unfortunately, in order to provide a proper fix, I introduced a breaking change on version 2.2.0.
TL;DR
For your case, of an initialized collection property that is not a List<T>
, HashSet<T>
or Collection<T>
, you can use the new method: WithInitializedCollectionProperty
instead of WithCollectionProperty
.
Full story
If you are using the method WithCollectionProperty
for a collection property that is not a List<T>
, HashSet<T>
or a Collection<T>
, an exception will be thrown at runtime. In your case, since your property is of type ObservableCollection<T>
, the overload that accepts a Collection<T>
is picked and this generates an error.
What should happen in this case, is that the overload with ICollection<T>
, for initialized collection properties, should be picked instead. To prevent the necessity of specifying generic types when calling the method, now the WithCollectionProperty
overloads that accept ICollection<T>
are obsolete, new methods were created specifically for the ICollection<T>
: WithInitializedCollectionProperty
from epplus.dataextractor.
thank you, it works with WithInitializedCollectionProperty
from epplus.dataextractor.
Related Issues (17)
- Merged rows HOT 1
- NuGet package does not include xml-docs
- GetData RowTo HOT 1
- Guid as Property value HOT 4
- Please add support for EPPlus.Core HOT 6
- Upgrade EPPlus NuGet dependency HOT 2
- Strong Name Errorr HOT 2
- Is it possible to extract the comment text on a cell?
- Extract data with Collections explanation HOT 1
- Extend termination criteria
- convertDataFunc
- Anonymous types HOT 3
- [Request] WithProperty Row Skipping, Casting Override, Error Handling, & Data sanitization
- .NET 4.0 HOT 8
- add example for Extract convertDatafunc
- extended WithCollectionProperty HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from epplus.dataextractor.