1.) What is your FileData? Assuming it's marked as serializable, NHibernate should default to mapping it to a BLOB or varbinary depending on the dialect used during configuration. You then set the different dialects during different initialization routines depending on if you're testing or running production code. That's actually the entire intent behind the Dialect concept in a NHibernate configuration.2.) Assuming there's some scenario that it doesn't make any sense to use #1 in, you could always do it the long way, and just have a static string in a class that's initialized to a different value (BLOB vs varbinary) depending on your configuration. Then your CustomSqlTypeIs() would call that string holder. Or something along those lines. I'd have to say, in my experience, #1 is the way to go if you can help it :)
On Mon, Apr 27, 2009 at 9:49 PM, Action Jackson <[email protected]> wrote: > > > Does anyone know if it is possible to use conditional logic to > construct Fluent mappings? Specifically, I would like to take the > following mapping: > > public class MyFileMap : ClassMap<MyFile> > { > public WksFileMap() > { > Id(x => x.Id); > Map(x => x.FileData) > .CustomSqlTypeIs("varbinary(MAX)"); > } > } > > I would like to conditionally specify the custom sql type for the > FileData property. When testing, I would like to use SqlLite; thus, I > would need to use BLOB as the sql type since SqlLite does not support > the varbinary(MAX) sql type. However, in production, I would like to > keep the mapping above. Is there a way to do this in a clean way? I > came across a blog where ActiveRecord is used, allowing you to plug > into the initialization pipeline. However, I'm not using > ActiveRecord. Is there some similar event model I can look into? > > Thanks for any insights! > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
