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
|
When "With Check" is set on a relationship, LightSpeed generates a back reference (i.e UserAccountsByStatus), but when "With NoCheck" is set, a standard relationship is generated. I am running into issues with this when I change the Status of a UserAccount in code, it executes OnValidate for every UserAccount that is in the same status. Is this the intended behavior? Shouldn't this option only "Check" when a Relationship is created or is Enabled after being Disabled? Note: It's currently re-validating 14,000 records every time a status is changed. |
|
|
Validation is checked every time you manually call .Validate(), access the .IsValid property, or when you are saving changes on a UnitOfWork - see http://www.mindscapehq.com/documentation/lightspeed/Creating-Domain-Models/Validation - if one of these three things is occurring then yes this is intended. If you want to avoid validation for that specific association you can disable the validation checking across associations either at a per association level or for an entire type. To disable it on a specific association apply a [ValidationNoTraverse] attribute to the association property, or for an entire type apply a [ValidationIgnoresAssociations] attribute to the class. You can specify these via the CustomAttributes property for the association or the entity in question in the designer.
|
|
|
Under what conditions is the "By" collection generated? |
|
|
The "ByX" suffix gets added when an entity has more than one association back to the entity in question, or you have two associations with the same name so we suffix the association so you dont end up with two properties with the same name (leading to a compilation error).
|
|
|
I have the following tables: fwMenu fwPortal ALTER TABLE [dbo].[fwMenu] WITH CHECK ADD CONSTRAINT [FKfwMenufwPortal] FOREIGN KEY([PortalId]) REFERENCES [dbo].[fwPortal] ([Id]) The attached image shows what is being generated based on the order that I add these tables to the Model. If I add fwMenu then fwPortal, it does not generate the ByX Reference. |
|
|
Yes I would agree that doesn't appear to be right but its hard to tell from a screenshot why this is occurring. Are you able to send through a copy of your .lsmodel file (in the initial state) and a script of your database schema so we can try and reproduce this here please. You can email these to us at support at mindscape.co.nz if preferred. Once we can reproduce this I can look into implementing a fix if this is indeed a bug.
|
|
|
I sent an email containing the project and database to the support email address. In the interest of keeping this post helpful to other that may run into the same issue, I am providing further details about the replication of the issue below. fwMenu fwPortal fwMenu.Parent_MenuId has an FK Relationship to fwMenu.Id It appears that the Parent_MenuId relationship is causing the PortalId relationship to generate the ByX collection depending on which Entity is added to the designer last. I don’t think that any of the relationships in this database should be generating the ByX collection. |
|
|
Thanks for sending that though, this is definitely unintended behavior but you are right it is being caused because of the naming on the self-reference association matching the naming on the other one. I am looking into correcting this as the conflict resolution only needs to occur on the entity itself. Hope to have an update on this shortly.
|
|
|
Fixed beautifully; thanks for the incredibly fast response! |
|