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
|
Looked over example of how to do composite keys in LightSpeed (kinda need them for a Map Table), http://www.mindscape.co.nz/blog/index.php/2009/12/22/composite-keys-in-lightspeed-3/ This is a good article, explains it well... if I was writing the code behind from the designer I would be off to the races... however I'm using the designer and it creates the code-behind for me. It would be really helpful if you could tell me how I achieve the same results in the designer. I can't see anyway to specify a UserDefined Structure as the Generic to use in the Entity<> input. am I missing something? the only choices I see that will allow me to specify are string, guid, int32 and int64.. Suggestions? |
|
|
We normally expect that if you're using composite keys, you're working against an existing database. (We recommend against the use of composite keys for greenfield databases.) In this case, you should just be able to drag the table onto the designer, and it will create the composite key for you. If you do need to do it manually, you have to do it a bit differently from using the Identity Type drop down. Instead, you define a set of identity properties on the entity. These identity properties then get turned into the struct that the article talks about. The option to create identity properties isn't shown by default (again, because we expect CKs to come from dragging legacy database tables rather than being created model-first), so you have to go into one of the more obscure corners of the designer to do it. Here's how: * Go into the LightSpeed Model explorer (View > Other Windows > LightSpeed Model). * Expand the tree and select the entity which needs to have a composite key. * Right-click the entity and choose Add New Identity Property. Set the appropriate name and data type (e.g. ProductId and Int32). * To add more fields to the composite key, keep adding new identity properties. Incidentally, once you've added the first identity property, we start showing a new section on the entity surface, which you can right-click here instead of going into the tree view. Again, we'd generally advise avoiding composite keys in a greenfield database -- not sure what you mean by a map table, but if you're thinking of a many-to-many association table (what we call a "through table") then you'll probably find it easier to use a normal entity, a pair of one-to-many associations and a through association. Just a suggestion! Let us know if the above doesn't make sense -- happy to post more details if required. |
|
|
[quote user="ivan"]... if you're thinking of a many-to-many association table (what we call a "through table") then you'll probably find it easier to use a normal entity, a pair of one-to-many associations and a through association. Just a suggestion!...[/quote]
Yes that's exactly what I want to do, but I'm sorry, I'm not sure how to translate you english to actions in the designer... can you point me to a tutorial or instructions on how to accomplish this? ( I had asked this basic question in this forum entry: http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=3198&PostID=10554 ) |
|
|
This article: http://www.mindscape.co.nz/blog/index.php/2009/09/17/many-to-many-associations-in-the-lightspeed-designer/ should help -- let us know if you need more info! |
|