There is an issue related to constuctors of persistent types. We imply if you declare non-public constructor in persistent type:
-
It must be either invoked form some other consturctor of this type or its descendant (i.e. finally, there will be invoked "through" top-level public constructor)
-
Or you must add a special code there by your own to enable its direct invocation from your code.
Finally, such a constructor must look like:
public class TransactionInfo : Entity
{
...
// Only this assmebly may create or modify this instance
internal TransactionInfo()
{
...
// Your code is above this point
var thisType = typeof (TransactionInfo); // This type!
try {
Initialize(thisType);
}
catch (Exception e) {
InitializationError(thisType, e);
throw;
}
}
}
...
// Generic type
public sealed class AuditRecord<T> : AuditRecord
where T: Entity
{
...
// Only this assmebly may create or modify this instance
internal AuditRecord()
{
...
// Your code is above this point
var thisType = typeof (AuditRecord<>); // No T: you must refer to generic type definition here!
try {
Initialize(thisType);
}
catch (Exception e) {
InitializationError(thisType, e);
throw;
}
}
}
Practical example of fixing this issue is here: http://goo.gl/4Lq8
This code is injected by our aspects to any public constructors, but currently we don't touch other constructors (it is actually necessary only in top-level constructors, that can be invoked).
Please remember about this: if this isn't done, it will be pretty hard to find a bug.
This thread was imported from our support forum. The original discussion may contain more detailed answer.
asked
Jun 11 '10 at 10:42
Alex Yakunin
2971●4●4●12