Entity fields

Posts   
 
    
rai
User
Posts: 41
Joined: 25-Jan-2007
# Posted on: 04-Jun-2008 01:48:15   

I defined a class called bundlecontrol

public class BundleControl {

    private BundleControl()
    {
        //
    }
    private static string dbConnectionString()
    {
        return ConfigurationManager.AppSettings["Main.ConnectionString"];       
    }
    static public BundleControlEntity Get(int bundlecode)
    {
        DataAccessAdapter adapter = new DataAccessAdapter(dbConnectionString());
        BundleControlEntity bundle = new BundleControlEntity(bundlecode);
        adapter.Dispose();
         return bundle;
    }

}

I want to access the entity fields. BundleControlEntity bundle = BundleControl.Get(5);

      int testcopies = Convert.ToInt32(bundle.Copies);
      int testcuttoff = Convert.ToInt32(bundle.Cutoff);
      int minpages = Convert.ToInt32(bundle.MinPages);
      int maxpages = Convert.ToInt32(bundle.MaxPages);

The problem is that m not getting the required values.

when i check that database: i got the record.

Id minpages maxpages copies cutoff 5 68 104 50 70

i just want to know....what iam doin wrongl.

suggestions please

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 04-Jun-2008 09:48:36   

You are not fetching the entity from the database.

You should do the following:

            DataAccessAdapter adapter = new DataAccessAdapter(dbConnectionString());
            BundleControlEntity bundle = new BundleControlEntity(bundlecode);
            adapter.FetchEntity(bundle);
rai
User
Posts: 41
Joined: 25-Jan-2007
# Posted on: 04-Jun-2008 10:13:10   

Thanks walaa.....i really dont know how i missed that...

Thanks so much.