Skip to content

Commit 6867ec4

Browse files
author
Davy Brion
committed
fix NH-1904
SVN: trunk@4682
1 parent e50c727 commit 6867ec4

File tree

5 files changed

+80
-6
lines changed

5 files changed

+80
-6
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using NUnit.Framework;
5+
6+
namespace NHibernate.Test.NHSpecificTest.NH1904
7+
{
8+
[TestFixture]
9+
public class Fixture : BugTestCase
10+
{
11+
[Test]
12+
public void ExecuteQuery()
13+
{
14+
using (ISession session = OpenSession())
15+
using (ITransaction transaction = session.BeginTransaction())
16+
{
17+
Invoice invoice = new Invoice();
18+
invoice.Issued = DateTime.Now;
19+
20+
session.Save(invoice);
21+
transaction.Commit();
22+
}
23+
24+
using (ISession session = OpenSession())
25+
{
26+
IList<Invoice> invoices = session.CreateCriteria<Invoice>().List<Invoice>();
27+
}
28+
}
29+
30+
protected override void OnTearDown()
31+
{
32+
base.OnTearDown();
33+
using (ISession session = OpenSession())
34+
{
35+
session.CreateQuery("delete from Invoice").ExecuteUpdate();
36+
session.Flush();
37+
}
38+
}
39+
}
40+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
3+
assembly="NHibernate.Test"
4+
namespace="NHibernate.Test.NHSpecificTest.NH1904">
5+
6+
<class name="Invoice">
7+
<id name="ID" type="Int32">
8+
<generator class="hilo" />
9+
</id>
10+
11+
<property name="Issued" type="DateTime" />
12+
</class>
13+
14+
</hibernate-mapping>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.NH1904
4+
{
5+
public class Invoice
6+
{
7+
public virtual int ID { get; private set; }
8+
public virtual DateTime Issued { get; set; }
9+
10+
protected virtual DateTime issued { get; set; }
11+
}
12+
}

src/NHibernate.Test/NHibernate.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@
556556
<Compile Include="NHSpecificTest\NH1898\SampleTest.cs" />
557557
<Compile Include="NHSpecificTest\NH1899\DomainClass.cs" />
558558
<Compile Include="NHSpecificTest\NH1899\SampleTest.cs" />
559+
<Compile Include="NHSpecificTest\NH1904\Fixture.cs" />
560+
<Compile Include="NHSpecificTest\NH1904\Model.cs" />
559561
<Compile Include="NHSpecificTest\NH1907\Fixture.cs" />
560562
<Compile Include="NHSpecificTest\NH1907\MyType.cs" />
561563
<Compile Include="NHSpecificTest\NH1908\Fixture.cs" />
@@ -1973,6 +1975,7 @@
19731975
<EmbeddedResource Include="Criteria\Lambda\Mappings.hbm.xml" />
19741976
<EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" />
19751977
<Content Include="DynamicEntity\package.html" />
1978+
<EmbeddedResource Include="NHSpecificTest\NH1904\Mappings.hbm.xml" />
19761979
<EmbeddedResource Include="FilterTest\SimpleFiltered.hbm.xml" />
19771980
<EmbeddedResource Include="FilterTest\SimpleFilteredFiltersDefsOk.hbm.xml" />
19781981
<EmbeddedResource Include="FilterTest\WrongFilterDefInClass.hbm.xml" />

src/NHibernate/Properties/BasicPropertyAccessor.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,17 @@ internal static BasicSetter GetSetterOrNull(System.Type type, string propertyNam
130130
return null;
131131
}
132132

133-
// the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does
134-
// not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly
135-
// stating that casing should be ignored so we get the same behavior for both structs and classes
136-
PropertyInfo property =
137-
type.GetProperty(propertyName,
138-
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase);
133+
BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly;
134+
135+
if (type.IsValueType)
136+
{
137+
// the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does
138+
// not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly
139+
// stating that casing should be ignored so we get the same behavior for both structs and classes
140+
bindingFlags = bindingFlags | BindingFlags.IgnoreCase;
141+
}
142+
143+
PropertyInfo property = type.GetProperty(propertyName, bindingFlags);
139144

140145
if (property != null && property.CanWrite)
141146
{

0 commit comments

Comments
 (0)