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
|
Imagine next db-model: and this result of LightSpeed modeler:
The question is: how I should use a table with compostie key in that situation? According to your articles Generated code of ACP_DEST table: [Serializable] [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")] [System.ComponentModel.DataObject] [Table("ACP_DEST")] public partial class AcpDest : Entity { #region Fields [Column("SOME_CLIENT")] [ValidateLength(0, 20)] private string _someClient; [ValidateUnique] private System.Nullable _fild; [ValidateUnique] private System.Nullable _subjd; #endregion #region Field attribute and view names /// Identifies the SomeClient entity attribute. public const string SomeClientField = "SomeClient"; /// Identifies the Fild entity attribute. public const string FildField = "Fild"; /// Identifies the Subjd entity attribute. public const string SubjdField = "Subjd"; #endregion #region Relationships [ForeignKeyField("Subjd")] [ReverseAssociation("AcpDests")] private readonly EntityHolder _source = new EntityHolder(); #endregion #region Properties [System.Diagnostics.DebuggerNonUserCode] public AcpSrc Source { get { return Get(_source); } set { Set(_source, value); } } [System.Diagnostics.DebuggerNonUserCode] public string SomeClient { get { return Get(ref _someClient, "SomeClient"); } set { Set(ref _someClient, value, "SomeClient"); } } [System.Diagnostics.DebuggerNonUserCode] public System.Nullable Fild { get { return Get(ref _fild, "Fild"); } set { Set(ref _fild, value, "Fild"); } } [System.Diagnostics.DebuggerNonUserCode] public System.Nullable Subjd { get { return Get(ref _subjd, "Subjd"); } set { Set(ref _subjd, value, "Subjd"); } } #endregion } |
|
|
Hi Dtgyr, I had a similar issue and was able to resolve by writing a few lines of custom association resolver. The visual designer has limited support for associations on composit keys. The designer expects the foreign key to be made up of just one field, and not be the same the same as the primary key field. That's why it gives you just one field to associate the relationship to. If your composite primary key is also foreign key you'll have to write a custom association resolver, which basically overides LightSpeed's default way of wiring up objects together and follows a custom logic. I had the same issues when I was trying to model on my legacy data bases, ran into a lot of cross cutting composite keys. With Ivan's help I was able to get this working, please read the full thread here: http://www.mindscapehq.com/forums/Thread.aspx?ThreadID=4134. You will need the latest nightly build to have it working properly. |
|
|
Disclaimer: I am not an offical Ambassador of LightSpeed, just a fan of the product :) |
|
|
Thank you. Now I'm trying to follow the thread you have specified, as guide. |
|