CSLA 3.6.3 BUG: Linq query on nullable of guid type property failedCSLA 3.6.3 BUG: Linq query on nullable of guid type property failed
Old forum URL: forums.lhotka.net/forums/t/7207.aspx
Baumus posted on Wednesday, July 01, 2009
Hi,
first of all I would like to say, I am really faszinated by the CSLA framework, its ongoing development and enhancements, it is really some great piece of work!
I have used CSLA 3.6.2 so far. After having upgradet to CSLA 3.6.3 the following LINQ query on a BusinessListBase object, failed:
Dim mGuid = mBusinessListBase.Last.mGuid
The Property mGuid is defined as follows in the child object (Inherited from BusinessBase):
Private Shared mGuidProperty As PropertyInfo(Of Guid?) = RegisterProperty(Of Guid?)(GetType(ChildObject), New PropertyInfo(Of Guid?)("mGuid", "mGuid"))
''' <Summary>
''' Gets and sets the mGuid value.
''' </Summary>
Public Property mGuid() As Guid?
Get
Return GetProperty(Of Guid?)(mGuidProperty)
End Get
Set(ByVal value As Guid?)
SetProperty(Of Guid?)(mGuidProperty, value)
End Set
End Property
Returning back to CSLA 3.6.2 the same code works perfectly. Am I correct assuming there is a bug in CSLA 3.6.3 because of that result? If yes, would it be possible to correct it?
Baumus replied on Wednesday, July 01, 2009
Baumus:
I have used CSLA 3.6.2 so far. After having upgradet to CSLA 3.6.3 the following LINQ query on a BusinessListBase object, failed:
Dim mGuid = mBusinessListBase.Last.mGuid
The Property mGuid is defined as follows in the child object (Inherited from BusinessBase):
Private Shared mGuidProperty As PropertyInfo(Of Guid?) = RegisterProperty(Of Guid?)(GetType(ChildObject), New PropertyInfo(Of Guid?)("mGuid", "mGuid"))
''' <Summary>
''' Gets and sets the mGuid value.
''' </Summary>
Public Property mGuid() As Guid?
Get
Return GetProperty(Of Guid?)(mGuidProperty)
End Get
Set(ByVal value As Guid?)
SetProperty(Of Guid?)(mGuidProperty, value)
End Set
End Property
Returning back to CSLA 3.6.2 the same code works perfectly. Am I correct assuming there is a bug in CSLA 3.6.3 because of that result? If yes, would it be possible to correct it?
I would just like to add some other odd behavior probably related somewhat to what I mentioned above. When I mark the above described property as indexable then I get the following exception:
NullReferenceException in System.Linq.Index<T>
private void DoAdd(T item)
{
if (_theProp != null)
{
int hashCode = _theProp.GetValue(item, null).GetHashCode(); // <--- this line is producing the error
if (_index.ContainsKey(hashCode))
_index[hashCode].Add(item);
else
{
List<T> newList = new List<T>(1);
newList.Add(item);
_index.Add(hashCode, newList);
}
_countCache++;
}
}
This error occurs in both CSLA 3.6.2 and CSLA 3.6.3 - what can be done about it?
AaronErickson replied on Sunday, July 05, 2009
Hi there-
I have created a test in the CSLA test project that adds getting the last item when a property is a Nullable Guid - and there seems to be no issues.
I suspect there is something else going on here, as I added CslaQueryProviderTests.TestLastWithNullableGuid to exercise this.
Simply having a property that is a Nullable and adding it to a BLB and/or querying it's last item is not a problem - as the test would fail if it were.
I suspect we will need to see what else is going on here to solve this. For fastest response, please provide a self-contained failing test which exercises the issue. If that is not possible, we will need to make further arrangements which will take longer to get set up and tested.Copyright (c) Marimer LLC