for "2 own its own..." I mean that Ms has 2 SqlBlahParameter for DbType.Time and two for DbType.Date. Another strange behavior of Ms-SQL-team is that for DateTime the have talked with ADO.NET team and they have introduced DbType.DateTime2 so... for DateTime we have 2 DbType respectively named DbType.DateTime and DbType.DateTime2 and we are managing both for MsSQL2005 and MsSQL2008. But for DbType.Date and DbType.Time we should do something else....
This is another example of how Ms-SQL-team apply : “The art of turning an easy thing in a difficult one, through a unnecessary procedure.” You can find some others nice inventions here : http://fabiomaulo.blogspot.com/2009/07/art-to-invent-mssqls-artists.html <http://fabiomaulo.blogspot.com/2009/07/art-to-invent-mssqls-artists.html> On Sat, Sep 4, 2010 at 8:14 AM, Fabio Maulo <[email protected]> wrote: > We have it already in NH. > The problem is, as said, that there isn't a DbType for NVARCHAR(MAX) and > for DbType.Date and DbType.Time Ms has 2 of its own SqlBlahParameter. > > About entity-name: > http://tinyurl.com/2vhhjck > the first two links are > > http://nhforge.org/blogs/nhibernate/archive/2008/10/21/entity-name-in-action-a-strongly-typed-entity.aspx > <http://nhforge.org/blogs/nhibernate/archive/2008/10/21/entity-name-in-action-a-strongly-typed-entity.aspx> > http://nhforge.org/blogs/nhibernate/archive/2008/10/31/entity-name-in-action-entity-abstraction.aspx > > > On Sat, Sep 4, 2010 at 7:16 AM, Frans Bouma <[email protected]> wrote: > >> > NH does not have any workaround to fix Time and Date issues; Ms should >> > respect its rules instead fix some rule and then do anything else. >> >> yeah, I agree, though debates with the team have lead to the >> conclusion for them that they won't change it. :/ >> >> > About sql-type it is an attribute of column tag (note a property can be >> > represented in more than one column). >> >> Ok. Here's a thought: >> - if you make sql-type part of 'property' as well, and IF it's specified >> you >> can use it to obtain the real <provider specific>DbType enum value and >> then >> set the real type enum property on the DbParameter instance. >> - at startup you obtain the enum type, by using a name stored in the >> dialect, e.g. OracleDbType. >> - you also create at startup a delegate at runtime with IL which will set >> the specific enum type property (obtained through reflection from a >> dbparameter instance, and with a name stored in the dialect). >> - When you create a parameter, you use the name stored in sql-type to >> obtain >> the enum value, use that value with the in-memory created delegate to set >> the specific type. >> >> This can be done in generic code. >> >> > entity-name is documented in various posts and in the coming soon : >> > NHibernTe 3 Cookbook >> >> I must have used the wrong google search terms then, because I couldn't >> find >> anything. Anyway, it was a wild guess if it would help me with the problem >> I >> had in another thread. >> >> FB >> >> > >> > -- >> > Fabio Maulo >> > >> > >> > El 03/09/2010, a las 06:31, Frans Bouma <[email protected]> escribió: >> > >> > >> On Thu, Sep 2, 2010 at 16:13, Frans Bouma <[email protected]> wrote: >> > >> > Look closer, it's right there :-) >> > >> > >> > >> > Schema: >> > >> > <xs:element name="property"> >> > >> > <xs:complexType> >> > >> > ... >> > >> > <xs:attribute name="type" type="xs:string" /> <xs:attribute >> > >> name="column" >> > >> > type="xs:string" /> <xs:attribute name="length" >> > >> type="xs:positiveInteger" >> > >> /> >> > >> > <xs:attribute name="precision" type="xs:positiveInteger" /> >> > >> <xs:attribute >> > >> > name="scale" type="xs:nonNegativeInteger" /> ... >> > >> > >> > >> > Example: >> > >> > <property name="StringData" length="100" /> >> > >> >> > >> >> > >> v3 specific? >> > >> >> > >> I looked at the nhforge ref docs and it wasn't there. If >> this >> > >> is >> > >> already valid for v2.1, I'll add support for it very soon :). When >> > >> these >> > >> elements are available in the mappings, the dialect picks them up >> > > for >> > >> parameter production like the call you showed in a query? >> > >> >> > >> It's missing in the docs (patch welcome ;-)), but it's in the schema. >> > >> And yes, it's used when creating the parameters. >> > > >> > > Ok! I checked the .xsd, and indeed they're there. One important >> > > element is missing though: sql-type (not from the xsd, but as an >> > > element to support it). You can use that at runtime to set the DB >> > > specific type in the parameter (instead of using the buggy DbType >> > > property) using a simple enum type lookup and an IL based property >> > > setter you generate at runtime at startup in the dialect. I haven't >> > > checked how NH works around this issue >> > > ( >> https://connect.microsoft.com/VisualStudio/feedback/details/381934/sq >> > > lparam >> > > eter-dbtype-dbtype-time-sets-the-parameter-to-sqldbtype-datetime-inste >> > > ad-of- >> > > sqldbtype-time) where sqlserver 2008's Time type requires you to set >> > > the SqlDbType property on the SqlParameter to Time, because setting >> > > DbType to Time or anything else will set SqlDbType to DateTime, which >> > > will cause an exception. The only way to set it properly is to set the >> > > SqlDbType property of the SqlParameter object to Time. ('Date' has the >> > > same problem). Haven't checked, perhaps NH has specific code to work >> > > around this issue. Using the type specification in the mapping would >> > > help get around this, as can then simply use generic code to set >> parameter >> > types. >> > > >> > > Glancing over the xsd, there are many elements which have >> attributes >> > > which are undocumented. The main problem I have with providing docs >> > > for this is ... where to get the info from? :). >> > > length/precision/scale... that's obvious. But for example the >> > > <many-to-many> element has a lot of attributes which aren't in the >> > documentation (also not in the Hibernate docs btw). E.g. >> > > what does entity-name do as attribute?. Is there a source (except >> > > hunting down a code path through the sourcecode) where this info is >> > > obtainable from so a more complete xml reference doc can be created? >> > > >> > > FB >> > > >> > >> >> > >> Diego >> > >> >> > >> -- >> > >> You received this message because you are subscribed to the Google >> > >> Groups "nhusers" group. >> > >> To post to this group, send email to [email protected]. >> > >> To unsubscribe from this group, send email to >> > >> [email protected]<nhusers%[email protected]> >> . >> > >> For more options, visit this group at >> > >> http://groups.google.com/group/nhusers?hl=en. >> > > >> > > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups >> > "nhusers" group. >> > > To post to this group, send email to [email protected]. >> > > To unsubscribe from this group, send email to >> > [email protected]<nhusers%[email protected]> >> . >> > > For more options, visit this group at >> > http://groups.google.com/group/nhusers?hl=en. >> > > >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "nhusers" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]<nhusers%[email protected]> >> . >> > For more options, visit this group at >> > http://groups.google.com/group/nhusers?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<nhusers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> >> > > > -- > Fabio Maulo > > -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" 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/nhusers?hl=en.
