locked
multiple column unique identifiers RRS feed

  • Question

  • User-377461684 posted

    I have been working thru the Scott Hanselman videos and have been very impressed with dynamic data so far but I have run into something that is posing a problem for me.  I have two related table.

    Listed below.  Dynamic data is not displaying the up stream and down stream fields at all and the

    stream segment table with all three fields set to primary key because you can have a single stream segment id in there several times but with different up and down stream stateCodes.  But at the same time you can have the same up and down stream code for a stream segment.  Therefore all three columns are combined for a unique row.

    Stream_Segment varchar(50) not null
    Upstream_Shefcode varchar(10) not null
    Downstream_Shefcode varchar(10) not null

    stateCode table where code_identifier is primary key

    code_Identifier varchar(10) not null
    code_Name varchar(50) not null
    code_Description varchar(100) nullable
    code_Latitude float not null
    code_Longtitude float not null

    The stream segment table is then related to another table called diversions that has all three columns from the stream segment table but on the insert or edit pages for the diversions table it is only showing the first column stream_segment not up or down state codes.  Since they aren't unique the same stream segment numbers are appearing multiple times.  If i select one and do an insert it inserts the correct unique segment, up and down.  I can tell by the order in the source table. Interestingly enough in the screenshot it is appending a 1 to the end of the field name. screen shot attached.

    screenshot

    I know that the insert and edit pages for the stream segment table will be interesting because when they change the stream segment dropdown then i will have to change the valid up and down stream state codes to populate the other ddls. I know... tmi.

    Bottom line

    Does dynamic data offer a way OOTB to handle multiple column primary keys?

    Is the FK dropdown setting the text to the first text column in the related table then the value to the related id?

    When trying to set the data type edit/insert templates is there a way to set varchar 's that are over a certain length to be multirow?

    Sorry for all the questions but i am excited about how much work this could save me in the very near future and i can't find any other resources on the topic yet.

    I tried the latest wizard to no avail.

    Thanks if you have even read this far.  :)

     

    Wednesday, August 27, 2008 3:13 AM

All replies

  • User-797310475 posted

    Does dynamic data offer a way OOTB to handle multiple column primary keys?

    Is the FK dropdown setting the text to the first text column in the related table then the value to the related id?

    When trying to set the data type edit/insert templates is there a way to set varchar 's that are over a certain length to be multirow?

    1. Yes, DD supports composite PKs

    2. Yes, we have a heuristic that chooses which column to use for display purposes in the foreign key dropdowns. You can override it by applying the DisplayColumnAttribute to your entity type. If you want to construct a display string from multiple columns you can declare a new read-only property in your partial class that returns the result that you want and use the name of that property as the input to DisplayColumnAttribute (note, this will only work in Linq To SQL, in EF you could try to just override the ToString method of the entity).

    3. Dynamic Data will automatically detect DB types such as varchar(max) or text and display them as multi-row. If you want to for certain varchar(n) columns to display as multi-row you could apply DataTypeAttribute(DataType.MultilineText) to them.

    Thursday, August 28, 2008 5:15 PM