How to comb non Identity Guid

43 views
Skip to first unread message

mwpowellhtx

unread,
Oct 9, 2014, 4:01:58 PM10/9/14
to fluent-n...@googlegroups.com
Hello,

I've got an Attachments table I am dealing with. Originally the data was table-bound VARBINARY(MAX), and the row ids were (are) BIGINT, etc.

The domain model, and related views and view models, are also, inexplicably, strongly coupled with the BIGINT (or C# long) Id property. There's enough there that I really don't want to muck with the Id one way or another if I can avoid it.

We are wanting to migrate the binary data from table to FILESTREAM, via SQL Server 2008 R2 and its features. So the data portion is easy enough. What we also need is the ROWGUIDCOL column added. In and of itself, no problem.

Except in the domain model mapping through the NHibernate ORM. How do we help the Guid column comb, while also not mucking with the Id? Is CompositeId an option with this sort of thing, but I didn't see anything in particular jump out at me there, either?

Any ideas? Thank you...

Best regards,

Michael

mwpowellhtx

unread,
Oct 9, 2014, 4:26:47 PM10/9/14
to fluent-n...@googlegroups.com
After doing a tiny bit of research, the following approach came to mind.

On the database side, we can make the assumption today SQL Server 2008 R2, and use the NEWSEQUENTIALID() strategy to help with fragmentation.

On the domain model side of things, the Id, will leave alone. It is still a long, mapped to BIGINT, etc. The Guid column, I suppose can be mapped to:

Map(x => x.DataGuid).Generated.Always();

And if I understand how VARBINARY FILESTREAM data works, the Guid is fine generated like that. The rest is handled through whether the corresponding Data mapping IS NULL, etc, along these lines.

Plausible? Short of some way to marry the two in a composite, which I'd like to avoid anyway, this seems like the best possible solution.

Thank you...

 
Best regards,

Michael

Oskar Berggren

unread,
Oct 12, 2014, 8:10:22 AM10/12/14
to fluent-n...@googlegroups.com
I'm not quite sure what's going on, but yeah if you just want to have the db-generated GUID available in the model, "Generated" seems like a reasonable idea.

/Oskar

--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibern...@googlegroups.com.
To post to this group, send email to fluent-n...@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.

Michael Powell

unread,
Oct 12, 2014, 12:13:47 PM10/12/14
to fluent-n...@googlegroups.com
On Sun, Oct 12, 2014 at 7:10 AM, Oskar Berggren
<oskar.b...@gmail.com> wrote:
> I'm not quite sure what's going on, but yeah if you just want to have the
> db-generated GUID available in the model, "Generated" seems like a
> reasonable idea.

Well, the crux of it is, I can't simply swap a Guid for a long, even
though technically that's what it should be with FILESTREAM,
ROWGUIDCOL, etc. At least, not without more of a retrofit on the
domain model extend outwards into the user interface views, bindings,
etc, than I am wanting to pursue with this effort.

Generated it is.

Thank you for the second opinion.
> You received this message because you are subscribed to a topic in the
> Google Groups "Fluent NHibernate" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/fluent-nhibernate/onCQRoYnlxY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
Reply all
Reply to author
Forward
0 new messages