New Posts New Posts RSS Feed: What am I doing wrong?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

What am I doing wrong?

 Post Reply Post Reply
Author
philpastor View Drop Down
Newbie
Newbie
Avatar

Joined: 09-Apr-2008
Location: United States
Posts: 9
Post Options Post Options   Quote philpastor Quote  Post ReplyReply Direct Link To This Post Topic: What am I doing wrong?
    Posted: 22-Apr-2008 at 1:19pm
Thanks, Bill ... that did it.
 
I would have thought that since I was calling create entity on the manager that it already knew about it :-/
 
Thanks again,
 
Phil
Back to Top
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Posted: 22-Apr-2008 at 12:57pm
After creating comp, add it to the PersistenceManager cache
 
comp.AddToManager();
 
 
Bill
 
Back to Top
philpastor View Drop Down
Newbie
Newbie
Avatar

Joined: 09-Apr-2008
Location: United States
Posts: 9
Post Options Post Options   Quote philpastor Quote  Post ReplyReply Direct Link To This Post Posted: 22-Apr-2008 at 11:25am
I have the following select query which works fine ...
 
DomainModel.Manager manager = new DomainModel.Manager();
var query = manager.Companies;
foreach (DomainModel.Company comp in query)
{
   textBox1.Text += comp.CompanyName;
}
if (textBox1.Text.Length == 0)
{
   MessageBox.Show("No Companies");
}
 
... but, I cannot create a new record ...
 
DomainModel.Manager manager = new DomainModel.Manager();
DomainModel.Company comp = manager.CreateEntity<DomainModel.Company>();
comp.CompanyName = textBox1.Text;
comp.CompanyId = 1;
List<DomainModel.Company> list = new List<DomainModel.Company>();
list.Add(comp);
 
SaveOptions options = new SaveOptions();
options.ThrowExceptionOnSaveFailure = ThrowExceptionRule.Always;
manager.SaveChanges(list, options);
 
... it runs fine (no errors), but it does not create a new record in the db. So, what am I doing wrong?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down