Middle Tier Questions

Posts   
 
    
samspam
User
Posts: 7
Joined: 24-May-2009
# Posted on: 24-May-2009 20:47:00   

Hi, Pretty new to all this. I cant seem to get my middle tier object to send me back a populated entity.

I am using adapter. I have a middle tier for business logic and data retrieval and updates, it inherits from the enitity. Like so:
public class ReleaseRequest : ReleaseRequestEntity

When I instantiate my middle tier object ReleaseRequest it automatically runs the default constuctor from ReleaseRequestEntity and produces a blank entity. This is fine for inserts. As I populate my object in the code behind and send it to the middle tier for logic and saving

But if I want to display data and send a populated ReleaseRequestEntity back to the UI so I can databind. I seem have to create a new populated entity. Rather than populating using the existing blank one created with the constructor.

Is there a way to do this, or should I not use this middle tier? Should the asp.net code behind page just talk directly with the entity? Not sure how I should design this?

Thanks in advance.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-May-2009 00:25:15   

Sure, it is possible. Look this tiny example of how this could be achieved:

// this class expose funcionallity related to Products
public class ProductManager
{

     // this method returns all products, ready for databinding.
     public EntityCollection<ProductEntity> GetAllProducts()
     {
          EntityCollection<ProductEntity> productsToReturn = new EntityCollection<ProductEntity>();
          using (DataAccessAdapter adapter = new DataAccessAdapter())
          {
               adapter.FetchEntityCollection(productsToReturn, null);
          }

          return productsToReturn;
     }

     // this method add a new product
     public void AddNewProduct(ProductEntity productToAdd)
     {
          ....
     }

     // ... other methods
}

The EntityCollections are ready for databinding. You just need to clarify your architecture. For additional info on databinding, read the Databinding section of the manual.

David Elizondo | LLBLGen Support Team
samspam
User
Posts: 7
Joined: 24-May-2009
# Posted on: 25-May-2009 07:40:18   

Thanks for the tip. Got it working now.