Jeff-Lewis / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

Framework CSLA: Instance property of DataAccessLayer must return derived class, not base class. #155

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Extracted from: http://community.codesmithtools.com/forums/t/10213.aspx
-------------------
Note: I attatch the solution that works for me to the file 
ParametrizedSQLBase.cst
-------------------

The instance property of Base.MyNameDataBase (in generated 
DataAccessLayerBase.vb) is declared as follow by the codesmith template:

    Public Shared ReadOnly Property Instance() As MyNameDataBase (<-- name 
of base class)
        Get
            Return Nested.Current
        End Get
    End Property

If the Instance property return the base class, I can't use the methods 
declared in the derived class.

For example, the call to MyNameData.Instance.MyCustomMethod() results in 
that the compiler give one error because the MyCustomMethod not belong to 
the base class, but the derived class.

If I change the follow in generated file DataAccessLayerBase.vb, then the 
call works fine:

Public Shared ReadOnly Property Instance() As MyNameData (<-- derived 
class, not base class)
    Get
        Return Nested.Current
    End Get
End Property
Private Class Nested
    Shared Sub New()
        Current = New MyNameData (<-- derived class, not base class)
    End Sub
    '' <summary>
    '' Current singleton instance.
    '' </summary>
    Friend Shared ReadOnly Current As MyNameData (<-- derived class, not 
base class)
End Class

------------------------- END

Original issue reported on code.google.com by bernyrod...@gmail.com on 6 Oct 2009 at 1:49

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 6 Oct 2009 at 1:59

GoogleCodeExporter commented 9 years ago
Hello,

This has been fixed in the latest build of the CSLA Templates.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 22 Oct 2009 at 7:17

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Jun 2010 at 8:10

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 15 Jul 2010 at 2:21