Hi there all.
Another VERY newbie on board
.
I need to replicate an entity.
A bit of background:
Client app, Remoted class with host, Original Northwind sql DB, an empty Northwind2 with same schema as the original Northwind.
1) Client app connects to remoted class that creates an Entity object from the original Northwind database and passes it back as an IEntity2;
2) Modify some entity properties….(see below)
3) Client app create a new DataAccessAdapter pointing to Northwind2 and tries to save the entity.
I’ve tried but I must be missing something.
Cheers,
Some source code:
My remoted class method.
public IEntity2 GetCustomer(string strCustomerID)
{
IEntity2 en = new CustomersEntity(strCustomerID);
DataAccessAdapter da = new DataAccessAdapter();
IPrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.CustomersEntity);
prefetch.Add(CustomersEntity.PrefetchPathOrders).SubPath.Add(OrdersEntity.PrefetchPathProducts);
da.FetchEntity(en,prefetch);
return en;
}
In the client:
private void button1_Click(object sender, System.EventArgs e)
{
IEntity2 en = userControl.GetCustomer("ANTON");
DataAccessAdapter da = new DataAccessAdapter();
//en.IsNew = true; // :-( does not work, no sql activity on nw2
//en.Fields.State = SD.LLBLGen.Pro.ORMSupportClasses.EntityState.New; // :-( does not work, no sql activity on nw2
en.PrimaryKeyFields[0] = "ANT22"; //still luck either
da.SaveEntity(en);
}
App.config (snip)
<appSettings>
<add key="Main.ConnectionString" value="data source=localhost;initial catalog=Northwind2;integrated security=SSPI;persist security info=False;packet size=4096"/>
<add key="CatalogNameUsageSetting" value="1"/>
<add key="CatalogNameToUse" value="Northwind2" />
</appSettings>