This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have the following table structure Deliverable - Totr - Opportunity
The totr entity has a unique constraint on field X however the generated sql to check the constraint uses Deliverable as the query:
SELECT COUNT(*) FROM Deliverable WHERE ((Totr.NLReference = 'NlRef' AND Deliverable.Id <> 1) AND Deliverable.DeliverableTypeId = 1)
|
|
|
Could you post the query please? Also note we have made some fixes to class table inheritance in recent nightly builds so you may want to update to the latest nightly. |
|
|
Hi Ivan, I am using the nightly build from 6th of july. Forgive the rather hasty post from yesterday. Basically i have 3 tables: - Deliverable ---Totr ---Opportunity Totr and Opportunity inherit from Deliverable.
Opportunity has some required fields nothing to fancy, the following tests works great:
[TestMethod] public void TestInsertOpportunityInsertsParentDeliverable() { string randomString = Guid.NewGuid().ToString(); var ot =new OpportunityType() { Name = randomString, }; var o = new Opportunity() { Title = randomString, OpportunityType = ot }; try { this._uow.Add(o); this._uow.SaveChanges(true); } catch (Exception e) { Assert.Fail(e.Message); } var deliverable = this._uow.FindById(o.Id); Assert.IsNotNull(deliverable, "Adding an opportunity doesnt add a parent deliverable"); Assert.IsTrue(randomString == deliverable.Title); Assert.IsTrue(deliverable.DeliverableType.Name == "Opportunity"); } |
|
|
Thanks for drawing our attention to this. It was actually a rather more general issue with Count queries in class table inheritance. I have committed a fix and it will be included in the 9 July nightly, available from about 1500 GMT. Let us know if you still see problems. Regarding the NLReference implementation, the best thing to do is probably to set its Generation option to FieldOnly. You can then implement the C# property in the partial class and make the setter private. Do not modify the _nLReference backing field directly. Changes to persistent fields should always go through the Entity.Set method (see the .lsmodel generated code for the pattern). Making your Saving and Validating code go through a (private) property setter, which calls Entity.Set, is a convenient way to achieve this. |
|