I have some problem with using dbContext Query method on base class which provide some inheritance to one other class (just for inherit properties, not for model / db building)
In my repo services I call something like:
IEnumerable<CoasterExtended> coasters = await _db.Query<CoasterExtended>()
.FromSql(GetCoastersProcedure, pageNumberParam, pageSizeParam, orderByParam, sortParam, breweryIdParam, searchParam, coasterTypeParam)
.ToListAsync();
GetCoastersProcedure is a sql procedure which return all properties of CoasterExtended class. This class is not used to model / db build. It is just mirror of sql procedure result.
In my OnModelCreating method i just have:
builder.Query<CoasterExtended>();
Querying the result of sql procedure worked fine until I decided to use this class for inheritance:
public class CollectionItemExtended : CoasterExtended {
// some additional properties
}
And the OnModelCreating method:
builder.Query<CollectionItemExtended>();
The query (of CoasterExtended type) now return error "The required column 'Discriminator' was not present in the results of a 'FromSql' operation". I know that discriminator is used for inherited types, but I use both classes to mirror the result of separate sql procedures (these results I simply map to desired app model classes)
So I dont want to select (and fake) discriminator ... I just want to map results of sql procedures to independent classes (which I have inherited just because I dont want to duplicate properties and mappers which are following). How can I achieve that the query result will ignore inheritance and just return the described types?