Recently I have quite tough time coding. Anything I touched, throws exception with messages that even google wasn’t eager to answer. Since I started developing my pet project ReMaster, it became a rule. I don’t know if it’s because of my rather small knowledge of the .net core or just the fact that I work on the ReMaster usually late in the night and I’m half asleep by the time. But never mind and let’s focus on my last problems and solutions.
Yeah, admit you are visiting this blog only for memes, huh?
Victories and Defeats
I managed to import companies data (finally!). It took me sooo much time mostly because I was struggling with the domain services pattern… I admit, my implementation of this is not sophisticated but for a long time I was scratching my head and searching for the answer if my code fits the pattern principles. I’m still not confident with that pattern so if there is a domain service mastah reading my blog, I would really appreciate a little code review ;).
Not solved problems
Well, I can’t add a field to AutoMapper’s Ignore properties list. I mean, I added it in my code but the property is still being mapped and I don’t know why! The situation gets stranger, since I found nobody else having the same problem in .net core projects. Am I doing something wrong or what? I coded a workaround for this problem by just setting the ignored property value to a temporary variable just before the mapping and setting it back from the variable just after mapping but there must be another way to do it!
Also I have strange exception with updating records in database (method AddInTransaction() if anybody wants to check the code). The error says:
The instance of entity type ‘Company’ cannot be tracked because another instance of this type with the same key is already being tracked. When adding new entities, for most key types a unique temporary key value will be created if no key is set (i.e. if the key property is assigned the default value for its type). If you are explicitly setting key values for new entities, ensure they do not collide with existing entities or temporary values generated for other new entities. When attaching existing entities, ensure that only one entity instance with a given key value is attached to the context.
That’s probably something totally silly and easy to solve but that’s enough coding for today!
.Net Core – always something new to surprise me!
I thought that .net core is on the market for long enough to have most of the classic .net features imported. That’s probably why, I couldn’t believe there is no TransactionOptions class! Really! And I wasn’t even able to find a confirmed information when (or even – if!) it will appear. Some people say about .net core v.1.2 (but I guess this version will never appear, right?) or about v.2.0. Other suggest using classic .net (excellent, really!).
Well, I decided not to use TransactionOptions at all. Problem solved ;).
Summary
After a few weeks of walking in a thick fog I’m starting to feel that I may be going the right path. It looks that the architecture problems and dilemmas are over and I’ll be able to code the flesh of my project. So it’s gonna be easier and the code should appear quicker… The time will show ;).