Providing an SQL Statement to SingleOrDefault causes exception Column t1$<ColumnName> not found
Latest pull from this morning Marshmallow branch. My code worked before the latest changes
I am providing a simple Sql statement to the TSession.SingleOrDefault<TCustomer> command. Although the TCustomer has ManyToOne relationships (Associates) I am not including them in the query as t1, t2 etc.
Select * from Customer where Sid = :0
The following exception occurs, when the TRowMapperInternal.MapEntityFromColumns tries to SetAssociations. It seems to be looking for the associates in the result set assuming that the query would provide them. This was not how this worked previously
Just curious if this is a bug or by design?
Comments (4)
-
reporter -
repo owner The change is by design - previously if the resultset did not contain the fields for an association you had a half or non initialized aggregation. If you want an entity without aggregations then you need to use a class without them.
-
reporter Stefan,
No disrespect intended, but are you suggesting that we need to have two instances of every Model Class, one with associations and one without in order to use the many methods of TSession that allow us to pass a Sql Statement?
Or do we need to now write Sql Statements with the aliases just right so that the main class is t0, first associate is expected to be t1, the second one t2 and so on? We write Sql on the fly this will require introspecting each class and adding associate sql dynamically.
Thanks,
Todd
--
-
repo owner - changed status to wontfix
- Log in to comment
BTW, Looking at my example Sql statment you might be thinking why is he not just getting by primary key, since in the example the sid field is our primary key. It just so happens the example I chose was just of the primary key, but the where clause can have any number of fields in it. Something like so.
Thanks