Worked like a charm. Brilliance...

On Apr 28, 12:01 am, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> Hrm, try something like this:
> Map(x => x.FileData)
>      .WithLengthOf(2147483647);
>
> I believe that should be the max size for varbinaries.
>
>
>
> On Mon, Apr 27, 2009 at 11:35 PM, Action Jackson <crjac...@gmail.com> wrote:
>
> >  Thanks! Removing the explicit call to CustomSqlTypeIs and adding the
> > explicit dialects for each back end seemed to make the difference.
> > Thank you very much for your help.  Not to be greedy, but would you
> > happen to know if it's possible to change the default mapping of byte
> > [] properties for MsSql from varbinary(8000) to varbinary(Max)? If
> > not, that's cool. You've helped plenty. Thanks again.
>
> > On Apr 27, 11:15 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> > > > are you saying that I should remove the explicit call to
> > "CustomSqlTypeIs"
> > > > and let NHibernate automatically take care of the conditional logic for
> > what
> > > > the Sql type should be?
>
> > > Yup :) This is the exact reason that dialects exist. Dialects are a way
> > to
> > > work with a database consistently, completely agnostic of the specific
> > > implementation nuances. In your case, the differences between MsSql and
> > > SqLite's binary container columns.
>
> > > On Mon, Apr 27, 2009 at 11:04 PM, Action Jackson <crjac...@gmail.com>
> > wrote:
>
> > > >  Hi Hudson, thank you for the quick response.  FileData is a byte
> > > > array (byte[]).  As for my database configuration, I am using the
> > > > SqlLite20Driver and the SQLiteDialect for testing purposes.  For your
> > > > #1 suggestion, are you saying that I should remove the explicit call
> > > > to "CustomSqlTypeIs" and let NHibernate automatically take care of the
> > > > conditional logic for what the Sql type should be?  Also, I noticed I
> > > > messed up the copy and paste job of my mapping. The constructor name
> > > > didn't match the class name.  Sorry for any confusion out there.
>
> > > >  public class MyFileMap : ClassMap<MyFile>
> > > >    {
> > > >         public MyFileMap()
> > > >         {
> > > >            Id(x => x.Id);
> > > >            Map(x => x.FileData)
> > > >                .CustomSqlTypeIs("varbinary(MAX)");
> > > >        }
> > > >    }
>
> > > > On Apr 27, 10:34 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> > > > > 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 <crjac...@gmail.com>
> > > > 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!- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to