Friday, June 19, 2009

Add new record using entity class

AppBreeder.EntityClasses.AppEntity app = new AppBreeder.EntityClasses.AppEntity();

app.UserId = 19;
app.Title = txtTitle.Text;
app.MainPageImg = txtMainPageImg.Text;
app.SplashScreenImg = txtSplashScreenImg.Text;
app.AppStoreIconImg = txtAppStoreIconImg.Text;
app.AppStoreName = txtAppStoreName.Text;
app.PrefCssSheet = txtPrefCssSheet.Text;
app.BlackBerryPubDate = System.DateTime.Now;
app.BlackBerryPubId = txtBlackBerryPubID.Text;
app.AndroidPubDate = System.DateTime.Now;
app.AndroidPubId = txtAndroidPubID.Text;
app.WebPubDate = System.DateTime.Now;
// app.WebPubId = txtWebPubID.Text;
app.AppType = dlsAppType.SelectedValue.ToString();
// AppBreeder.EntityClasses.

DataAccessAdapter adapter = new DataAccessAdapter();
adapter.SaveEntity(app);

Edit Existing Record

AppEntity application = new AppEntity(int.Parse(Session["AppID"].ToString()));
DataAccessAdapter adapter = new DataAccessAdapter(true);
adapter.FetchEntity(application);
application.Title = txtTitle.Text;
application.AppType = dlsAppType.SelectedValue;
adapter.SaveEntity(application);

note:
Fetch object before save

No comments:

Post a Comment