Open GoogleCodeExporter opened 9 years ago
Hello,
I believe that this is the correct behavior based on the following two
documents(http://www.lhotka.net/Article.aspx?id=4be29839-f6d8-4caa-b1ae-13b85563
90dc and
http://books.google.com/books?id=9Mbx3Svoc1EC&pg=PA444&lpg=PA444&dq=CSLA+Criteri
a+typeof&source=bl&ots=do7iUS1Xwy&sig=eB9WSkOs_D4TdaymWkUP_O4ehl0&hl=en&ei=4hqZT
NXrEtWMnQeDvMHLDw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CDAQ6AEwBQ#v=onepa
ge&q=CSLA%20Criteria%20typeof&f=false). I remember researching this but can't
remember. Could you please take a look or ask on Rocky's forums (he may be on
vacation).
Thanks
-Blake Niemyjski
Original comment by bniemyjski
on 21 Sep 2010 at 8:54
In order to reuse the criteria objects for different business objects we have
been doing the following:
<Serializable()> _
Public Class MaterialCriteria
Inherits Csla.CriteriaBase
Private Shared MaterialIDProperty As PropertyInfo(Of Guid) = RegisterProperty(Of Guid)(GetType(MaterialCriteria), New PropertyInfo(Of Guid)("MaterialID"))
Public ReadOnly Property MaterialID() As Guid
Get
Return ReadProperty(MaterialIDProperty)
End Get
End Property
Public Sub New(ByVal type As Type, ByVal materialID As Guid)
MyBase.New(type)
LoadProperty(MaterialIDProperty, materialID)
End Sub
Public Sub New()
End Sub
End Class
Then within each business object we provide the type as part of the Criteria
call, like the following:
DataPortal.Delete(Of Material)(New MaterialCriteria(GetType(Material),
materialID))
or
DataPortal.Delete(Of MaterialCatalog)(New
MaterialCriteria(GetType(MaterialCatalog), materialID))
We are just look at the reusablity of these criteria objects. I know this is
bad example since this criteria only has one parameter value and code have
simply used the SingleCriteria class.
Just a thought. Let me know what you think. Thanks.
Original comment by jodyches...@comcast.net
on 23 Sep 2010 at 5:10
Hello,
I could see where this could be useful if you have multiple entities from one
table and you want to reuse. However, it would be nice not to have to call
GetType. Do you know how this is supported in CSLA 4? Since this is supplied as
part of the class definition.
Thanks
-Blake Niemyjski
Original comment by bniemyjski
on 27 Sep 2010 at 12:10
The current CodeSmith CSLA templates are generating the following for vb 4.0
criteria objects:
Public Partial Class MaterialCriteria
Inherits CriteriaBase(Of MaterialCriteria)
Implements IGeneratedCriteria
....
#Region "Constructors"
Public Sub New()
End Sub
Public Sub New(ByVal uMaterialID As System.Guid)
Me.UMaterialID = uMaterialID
End Sub
#End Region
For the entity class, these templates are generating:
Friend Shared Function GetByUMaterialID(ByVal uMaterialID As System.Guid) As
Material
Dim criteria As New MaterialCriteria()
criteria.UMaterialID = uMaterialID
Return DataPortal.FetchChild(Of Material)(criteria)
End Function
All of this appears to be in-line with the idea the criteria class can be
independent from entities and thus re-usable as well.
Original comment by jodyches...@comcast.net
on 30 Sep 2010 at 5:32
Wondering what people think we should use for this. We had a request to move
this to use a BusinessBase implementation. Would this work for you?
Original comment by bniemyjski
on 5 Oct 2010 at 10:32
Does this mean each BusinessBase would have their own nested (private)
criteria?
Original comment by jodyches...@comcast.net
on 6 Oct 2010 at 2:16
Hello,
No, the criteria class would just inherit from BusinessBase instead of
ICriteria.
Thanks
-Blake Niemyjski
Original comment by bniemyjski
on 17 Nov 2010 at 3:53
Original comment by bniemyjski
on 9 Mar 2012 at 1:34
Original issue reported on code.google.com by
jodyches...@comcast.net
on 20 Sep 2010 at 4:55