This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Now that the Stack Overflow problem is fixed by changing my model to get rid of the circular reference, I am still not able to load anything using a composite key. The code in my unit test is as follows:
ProductDescription description = MultiKeyDepot.Find(new ProductDescriptionId(1, 1775)); The find function is written like this (it works just fine with a single integer key): public TEntity Find( The exception I am getting is as follows:
Mindscape.LightSpeed.LightSpeedException was unhandled by user code
Message=Unable to materialize field [LanguageId] on type [GoodTimeHobbies.DataAccess.ORM.ProductDescription]. Check your table has an Id column and that your mappings are correct. See inner exception for details. Source=Mindscape.LightSpeed StackTrace: at Mindscape.LightSpeed.LightSpeedException.Throw(Exception innerException, String format, Object[] values) in C:\src\Mindscape\Lightspeed\Src\Framework\LightSpeedException.cs:line 62 at Mindscape.LightSpeed.Model.FieldModel.Materialize(IDataProviderAdapter dataProviderAdapter, Object target, Object[] values, Int32& index) in C:\src\Mindscape\Lightspeed\Src\Framework\Model\FieldModel.cs:line 277 at Mindscape.LightSpeed.Mapping.EntityLoader.LoadEntityByFieldOrder(UnitOfWorkBase unitOfWork, String aggregateName, Entity entity, Object[] values, IColumnPermutation permutation) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\EntityLoader.cs:line 175 at Mindscape.LightSpeed.Mapping.EntityLoader.LoadEntityFromReader(AliasedTypeModel typeModel, Object id, Boolean allowUnscopedIdentifiers) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\EntityLoader.cs:line 90 at Mindscape.LightSpeed.Mapping.ObjectLoader.VisitTypeModel(AliasedTypeModel typeModel, QueryExpression queryExpression, Order order, Group group, String aggregateName, Boolean includeDeleted, Boolean identifiersOnly) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\ObjectLoader.cs:line 225 at Mindscape.LightSpeed.Mapping.QueryTraversal.Visit(LightSpeedContext context, List`1 typeModels, QueryExpression queryExpression, Order order, Group group, String aggregateName, Boolean includeDeleted, Boolean identifiersOnly) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\QueryTraversal.cs:line 35 at Mindscape.LightSpeed.Mapping.ObjectLoader.LoadFromQueryStrategy(AliasedTypeModel typeModel, IList results, String aggregateName, Boolean identifiersOnly) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\ObjectLoader.cs:line 159 at Mindscape.LightSpeed.Mapping.ObjectLoader.LoadInternal(TypeModel typeModel, Query query, IList results) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\ObjectLoader.cs:line 72 at Mindscape.LightSpeed.Mapping.ObjectLoader.Load(UnitOfWorkBase unitOfWork, TypeModel typeModel, Query query, IList results) in C:\src\Mindscape\Lightspeed\Src\Framework\Mapping\ObjectLoader.cs:line 19 at Mindscape.LightSpeed.QueryingEngine.FindInternal(Query query, TypeModel typeModel, IList results) in C:\src\Mindscape\Lightspeed\Src\Framework\QueryingEngine.cs:line 363 at Mindscape.LightSpeed.QueryingEngine.Find(Query query, IList results) in C:\src\Mindscape\Lightspeed\Src\Framework\QueryingEngine.cs:line 109 at Mindscape.LightSpeed.UnitOfWork.Find(Query query, IList results) in C:\src\Mindscape\Lightspeed\Src\Framework\UnitOfWork.cs:line 242 at Mindscape.LightSpeed.UnitOfWorkBase.Find(Query query) in C:\src\Mindscape\Lightspeed\Src\Framework\UnitOfWorkBase.cs:line 431 at Mindscape.LightSpeed.UnitOfWork.FindOne(Query query) in C:\src\Mindscape\Lightspeed\Src\Framework\UnitOfWork.cs:line 191 at Mindscape.LightSpeed.UnitOfWorkBase.FindOne[TEntity](Query query) in C:\src\Mindscape\Lightspeed\Src\Framework\UnitOfWorkBase.cs:line 267 at Mindscape.LightSpeed.UnitOfWorkBase.FindById[TEntity](Object id) in C:\src\Mindscape\Lightspeed\Src\Framework\UnitOfWorkBase.cs:line 171 at GoodTimeHobbies.DataAccess.API.Depot`1.Find(Object id) in C:\src\snap-ls\DataAccess\API\Depot.cs:line 49 at DataAccess.Tests.DepotTest.FindCompositeKeyTest() in C:\src\snap-ls\DataAccess.Tests\DepotTest.cs:line 109 InnerException: System.FormatException Message=Input string was not in a correct format. Source=mscorlib StackTrace: at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value, IFormatProvider provider) at Mindscape.LightSpeed.Data.DataProviderAdapter.GetInt32(Object[] values, Int32 index) in C:\src\Mindscape\Lightspeed\Src\Framework\Data\DataProviderAdapter.cs:line 140 at Mindscape.LightSpeed.Model.FieldModel.<>c__DisplayClass7d.<CreateValueSetter>b__57(IDataProviderAdapter dataProviderAdapter, Object target, Object[] values, Int32 index) in C:\src\Mindscape\Lightspeed\Src\Framework\Model\FieldModel.cs:line 684 at Mindscape.LightSpeed.Model.FieldModel.Materialize(IDataProviderAdapter dataProviderAdapter, Object target, Object[] values, Int32& index) in C:\src\Mindscape\Lightspeed\Src\Framework\Model\FieldModel.cs:line 266 InnerException: |
|
|
Any updates on this one? |
|
|
Ok, I have realized after re-reading the docs on composite keys a few more times, that the core issue here is that the designer will NOT properly implement composite key'ed entities because it will not set up the GeneratedId() method overload, which is the root cause of this problem: Not to mention that I have to manually add in the foreign key associations path as Id.ProductId etc. When I do this, it removes the composite key values from the entity itself, which means all my LINQ that does joins no them is broken :(. The best solution to this problem is to simply drop using composite keys, and change over to surrogate keys. That is what I am going to be doing right now :) |
|