Thanks but afraid this won't work as I would then have to define a property
within UserAudit for the Action. Also I'd have to do the same for the Log
fields by making IAudit inherit ILog. Even then I'm still not sure this
would work.
On Friday, 10 July 2015 11:45:44 UTC+1, Gunnar Liljas wrote:
>
> "Now say I try to query for the audits by saying session.Query<Audit>().
> I have found this does a join against the "UserAudit" table even though I
> don't wish to display any of the "UserAudit" information."
>
> Yes, that's expected, since the UserAudits are Audits, and you wanted all
> Audits.
>
> Would this work?
>
> public interface IAudit {
> string Action { get; set; }
> }
>
> public class Audit : Log, IAudit {
> public virtual string Action { get; set; }
> }
>
> public class UserAudit : IAudit {
> public virtual User User { get; set; }
> }
>
> 2015-07-10 12:13 GMT+02:00 Lee Timmins <[email protected] <javascript:>
> >:
>
>> I have the following entities defined:
>>
>> public class Log {
>> public virtual int Id { get; set; }
>> public virtual DateTime DateCreated { get; set; }
>> }
>>
>> public class Audit : Log {
>> public virtual string Action { get; set; }
>> }
>>
>> public class UserAudit : Audit {
>> public virtual User User { get; set; }
>> }
>>
>> Note: Both "Audit" and "UserAudit" are mapped as sub-classes to their own
>> separate table in the database.
>>
>> Now say I try to query for the audits by saying session.Query<Audit>(). I
>> have found this does a join against the "UserAudit" table even though I
>> don't wish to display any of the "UserAudit" information. After some
>> research I discovered that I could add polymorphism explicit against the
>> "Log" mapping to prevent this. However this did not do anything. I'm
>> guessing it would work fine for session.Query<Log>() and the issue arises
>> because I am using multiple inheritance.
>>
>> I could change my structure to only use a single level of inheritance but
>> this is a lot of work for me at this stage. I'd appreciate it if anyone
>> could let me know if this is possible without having to change my entities
>> and database structure.
>>
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/nhusers.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.