Home All Groups Group Topic Archive Search About

Question about Inheritance

Author
28 Mar 2007 1:46 AM
Sridhar
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.

Author
28 Mar 2007 2:08 PM
KyleK
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?

--
Kyle Kelin
..NET Developer


Show quote
"Sridhar" wrote:

> 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.
Author
28 Mar 2007 2:36 PM
Sridhar
yes, I am getting a circular reference error. I am getting this error in .NET
2.0.

Show quote
"KyleK" wrote:

> 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?
>
> --
> Kyle Kelin
> .NET Developer
>
>
> "Sridhar" wrote:
>
> > 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.

AddThis Social Bookmark Button