c# - FluentNHibernate HiLo - can be maxLo read from table and not to be hardwired in code? -
i using
generatedby.hilo(string table, string column, string maxlo, string where);
for primary key. looking possibility how load maxlo table rather store constant in code. value nexthi loaded database table (ok, must otherwise whole concept not working @ all). did not find way how load maxlo table too. quick code study seems not possible, still maybe missing something.
reason why need it: have business application , separate config application needs use same maxlo consistency of ids if inserts tables. of course application can run exclusively. 2 possible workarounds: - can have shared dll maxlo stored - can use table in database , load maxlo on own
but still fine want without workarounds.
fluentnhibernate version: 2.0.1.0
i wish have the answer, mine is: no. have pass values setting. reason way how table hi-lo generator implemented.
check tablehilogenerator code .configure()
/// <summary> /// configures tablehilogenerator reading value of <c>table</c>, /// <c>column</c>, <c>max_lo</c>, , <c>schema</c> <c>parms</c> parameter. /// </summary> /// <param name="type">the <see cref="itype"/> identifier should be.</param> /// <param name="parms">an <see cref="idictionary"/> of param values keyed parameter name.</param> /// <param name="dialect">the <see cref="dialect.dialect"/> configuration.</param> public override void configure(itype type, idictionary<string, string> parms, dialect.dialect dialect) { base.configure(type, parms, dialect); maxlo = propertieshelper.getint64(maxlo, parms, int16.maxvalue); lo = maxlo + 1; // "clock over" on first invocation returnclass = type.returnedclass; }
the interesting part comment:
//configures tablehilogenerator reading value of <c>table</c>, // <c>column</c>, <c>max_lo</c>, , <c>schema</c> <c>parms</c> parameter.
and parameter idictionary<string, string> parms
in extreme case, can use (and fluent version: generatedby.hilo(...)
) - read properties somewhere (e.g. ado.net) , pass such values configuration... extreme, the answer
Comments
Post a Comment