SQL Filestream newsequentialid default value

5 posts, 0 answers
  1. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 14 Aug 2012 Link to this post

    I'm in the middle of implementing the FILESTREAM feature of SQL 2008 for storing BLOB data.

    In order to implement (according to FILESTREAM requirements), you MUST include a column in your table (the table that has the BLOB data) that is of:
    "uniqueidentifier rowguidcol" type
    The column MUST also be marked as NOT NULL.
    The column MUST also be marked as UNIQUE.

    I had wanted to take advantage of OpenAccess' new "default value" ability.  I wanted to use a default value in SQL of "newsequentialid()" for the column above.

    Putting all that together, the script for the column would look like this:
    [FSRowGuid] [uniqueidentifier] rowguidcol default newsequentialid() NOT NULL unique,

    Can anybody tell what issues there will be?

    Let's look at it from the ORM/OA side first...
    In order to use OA's default value, the field MUST BE marked as NULL.  This is in clear violoation of the FILESTREAM requirement of the column being marked as NOT NULL.  Given I NEED to use FILESTREAM, I guess my hopes of using OA's default value ability is out the window huh?

    Now... from the .NET perspective...
    Ok, so... I can't use OA's default value ability.  I'll just add that field value in code like I've done for years because of the OA's inability to have default values (up until now)...right?  WRONG.  .NET doesn't have any equivilent for "newsequentialid()" to be able to add the value manually.

    So, not only can I not use OA's default values, I can't use SQL's sequencialids either.  Great.

    Now I need to take that part out and go back to creating standard GUID values and manually inserting them with other data.

    Is this just sorta what we have to put up with?
    Or, is there a better answer that I'm not seeing?

  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 16 Aug 2012 Link to this post

    Hello Shawn,

     Only the conceptual representation of your column needs to be nullable. This said you can keep your column to not nullable and just set the nullability of your property to true. This will generate a nullable guide in your code in which we will be able to populate the default value generated by the server.

    All the best,
    Petar
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 16 Aug 2012 Link to this post

    I guess that will work.

    Thanks.

    I generally try not to have discrepencies between the actual database and the model as these types of things could easily get lost if the model needs to be re-generated for some reason (or even that object/table needs to be re-generated).
  5. Jacob
    Jacob avatar
    12 posts
    Member since:
    Mar 2013

    Posted 25 Mar 2013 Link to this post

    What is the best way to request new features? I'm encountering the same issue as Shawn, and it would be really great if OpenAccess included better functionality for database defaults. Relying on nulls as an indicator is extremely limiting and requires frustrating and often inconvenient and unideal work-arounds. Thanks.
  6. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 01 Apr 2013 Link to this post

    Hello Jacob,

     The best way for your ideas to receive publicity is though our ideas and feedback portal that can be found here.

    Kind regards,
    Petar
    the Telerik team
    Free Webinar: OpenAccess Integration in Sitefinity. SIGN UP NOW.
Back to Top
DevCraft banner