This is a migrated thread and some comments may be shown as answers.

SQL Filestream newsequentialid default value

4 Answers 77 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shawn Krivjansky
Top achievements
Rank 1
Shawn Krivjansky asked on 14 Aug 2012, 05:23 AM
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?

4 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 16 Aug 2012, 12:39 PM
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!
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 16 Aug 2012, 04:19 PM
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).
0
Rob
Top achievements
Rank 1
answered on 25 Mar 2013, 09:16 PM
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.
0
PetarP
Telerik team
answered on 01 Apr 2013, 12:21 PM
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.
Tags
General Discussions
Asked by
Shawn Krivjansky
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Shawn Krivjansky
Top achievements
Rank 1
Rob
Top achievements
Rank 1
Share this question
or