Question about Inheritance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a web application which accesses the data base. So I created a
dataaccesslayer project which has a separate class for each table. I have
also created a business layer to access these classes so that I can only
refer to the business layer from web project. I used inheritance in the
business logic classes to import the properties of the dataaccesslayer class
.. since I am not referring to the dataaccesslayer from web project the
compiler is giving an error when I try to run the application. Is there a
solution for this with out creating all the properties and methods in the
business layer? Following is the sample code that exemplifies what I am
trying to do.

' Inside web form

Dim objProducts as ProductsDTO = New ProductsDTO("1")
Dim productId as string = objProducts.ProductId

' Inside business logic

public class ProductsDTO
Inherits Products

public sub New(CustomerId)
MyBase.New(customerId)
End sub


'Inside DataAccessLogic

public class Products

private sub productId

public sub New(CustomerId)
Dim dtProduct as datatable

dtProducts = GetProductFromDB(CustomerId)
if not dtProducts is nothing
productId = dtProducts.rows(0).Item(ProductId)
end if
End sub

Please let me know.

Thanks,
sridhar.
 
Sridhar

I usually return a reader or datatable from my data access and then loop
through the reader in my business logic and assign it to the entitiy
property.

Are you getting a circular reference error? What is the actually compiler
error?
 
Back
Top