> > I think you miss something, because all works fine with the inline syntax > for null values... > > Example of SQL Insert : > > INSERT INTO TABLEXXX > ( > Column1, > Column2 > ) > VALUES > ( > #Id#, > #MyDate:DateTime:01/01/0001 00:00:00# > ) > > Then if you pass an object with its property MyDate sets to > DateTime.MinValue, a NULL value is inserted in the corresponding column. >
That's the point, Nicolas, the inline syntax works (even for me), the *equivalent* resultMap syntax does *not*. The question is: why. Andrea > Nicolas > > > -----Message d'origine----- > De : Andrea Tassinari [mailto:[EMAIL PROTECTED] > Envoyé : vendredi 28 septembre 2007 17:12 > À : [email protected] > Objet : Re: nullValue in ResultMap simply does not work > > At 15.30 28/09/2007, Bob Hanson wrote: > >>.NET 2.0 Nullable types will work correctly with null values. > > yes I can understand, but I don't like the idea to convert all DateTime > and Guid in nullable DateTime with obviuos consequences on my code. > > Anyway the iBatis manual states that the attribute "nullValue" in the > resultmap should work just fine as the inline semantics, I dont understand > if I'm experiencing a bug or I am missing something. > > Andrea > > >>On 9/28/07, Andrea Tassinari >> <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED] > wrote: >>Hello, >> >>I'm wondering why nullValue attribute does not work at all to me. >> Consider the following snippets >> >><!-- sqlMap --> >><resultMaps> >> <resultMap id="IssueResultMap" class="Issue"> >> <result property="Id" >> column="Id" >> type="Guid" >> dbType="UniqueIdentifier" /> >> <result property="IssueDate" >> column="IssueDate" >> type="DateTime" >> dbType="DateTime" >> nullValue="1/1/0001 12:00:00 AM" /> >> </resultMap > >></resultMaps> >> >><!-- this does **not** work, sqlclient complains about IssueDate--> >><insert id="Insert" parameterClass="Issue"> >> INSERT >> INTO ISSUES >> (Id, IssueDate) >> VALUES >> (#Id#,#IssueDate#) >></insert> >> >><!-- this **does** work --> >><insert id="InsertIssue" parameterClass="Issue"> >> INSERT >> INTO ISSUES >> (Id, IssueDate) >> VALUES >> (#Id#,#IssueDate:DateTime:1/1/0001 12:00:00 AM#) >></insert> >> >>//CS snippet >>Issue issue = new Issue(); >> >>//this is only for clarity sake, actually performed by the contructors. >>issue.IssueDate = new DateTime(); >> >>//finally persist to DB >>_mapper.Insert("InsertIssue", issue); >> >>Is there a reason for that? I am wrong or else? It *is* very boring and >> error-prone to write all nullValue condition in the inline form (consider >> that I have over 200 insert/update statements in my app. >> >>My system: >> >>.NET 2.0 >>iBatis DataMapper 1.6.1 GA binary version >>Sql Server 2.0 >>using provider sqlServer2.0 as shipped in providers.config >> >>Thanks for any support. >> >>-- >>Kind Regards >>Andrea >> >> >> >> >>No virus found in this incoming message. >>Checked by AVG Free Edition. >>Version: 7.5.488 / Virus Database: 269.13.33/1034 - Release Date: >> 27/09/2007 17.00 > > -- AndreaT

