Hello,
I'm getting this exception:
System.InvalidOperationException was unhandled
Message=Can not commit a transaction: ValidationContext is in inconsistent state.
Source=Xtensive.Orm
StackTrace:
at Xtensive.Orm.Transaction.CompleteValidation()
at Xtensive.Orm.Transaction.Commit()
at Xtensive.Orm.TransactionScope.Dispose()
at InconsistentState.Model.SessionTrace.TraceOpenedSession(Domain domain, Guid guid, String userId, String ipAddress)
at InconsistentState.Program.Main(String[] args)
with this code:
[HierarchyRoot]
public class SessionTrace : Entity
{
public static void TraceOpenedSession(Domain domain, Guid guid, string userId, string ipAddress)
{
using (Session session = domain.OpenSession())
using (TransactionScope t = session.OpenTransaction())
{
SessionTrace sessionTrace = new SessionTrace(session, guid);
sessionTrace.OpenedDate = DateTime.Now;
sessionTrace.UserIdentifier = userId;
sessionTrace.IpAddress = ipAddress;
t.Complete();
}
}
private SessionTrace(Session session, Guid sessionId)
: base(session, sessionId)
{
}
[Field, Key]
public Guid Id { get; private set; }
[Field]
public DateTime? OpenedDate { get; set; }
[Field]
public string UserIdentifier { get; set; }
[Field(Length = 50)]
public string IpAddress { get; set; }
[Field]
public DateTime? ClosedDate { get; set; }
}
Is this a bug? Am I doing something wrong?
DO.Net version: 4.4.2.8482
asked
Mar 16 '12 at 10:16
olorin
358●87●87●92
Hello olorin,
could you try making constructor of
SessionTrace
non-private?Hello Dmitri, This is working like a charm with a protected constructor.
Would it count as a workaround?
Yes it counts!