Hi...
I am developing a Windows App.
When I press a button, I create 3 inventory items,
I use Inventory.Create method
like
public static Inventory Create(string barcode, int fixedAssetID, int departmentID, int locationID, int? supplierID, DateTime receiptDate, decimal? price, int? currencyID, decimal? currentValue, string invoiceNo, DateTime? invoiceDate, int warrantyPeriod, int inventoryStatusID, int? purchaseOrderDetailID, bool checkedOut, int? leasingID, string description, string inventoryKeywords, bool waitingInApprovals, int? PermanentLocationID, string markOrModel, int? insuranceID, int? expensePointID, decimal? currentPrice)
{
Inventory aInventory = (Inventory)SessionParameters.Manager.CreateEntity(typeof(Inventory));
SessionParameters.Manager.GenerateId(aInventory, Inventory.PropertyMetadata.InventoryID);
aInventory.SomeProperties are set
..
..
}
Then I create 3 InventoryStaffs for each inventory record...
I use InventoryStaff.Create Method like
public static InventoryStaff Create(int inventoryID, int staffID, int? priority, string description, bool? waitingInApprovals)
{
InventoryStaff aInventoryStaff = (InventoryStaff)SessionParameters.Manager.CreateEntity(typeof(InventoryStaff));
SessionParameters.Manager.GenerateId(aInventoryStaff, InventoryStaff.PropertyMetadata.InventoryStaffID);
aInventoryStaff.InventoryID = inventoryID;
aInventoryStaff.StaffID = staffID;
...
...
}
then in my code..
I use
SaveOptions aSaceOption=new SaveOptions();
Type[] types = new Type[] { typeof(Inventory), typeof(InventoryStaff)};
aSaveOption.PersistenceOrder = types;
try
{
SessionParameters.Manager.SaveChanges(aSaveOption);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return;
}
But code drops to Exception saying there is foreign key problem with the two tables...
I change their order in typeof line...
but it did not change...
How will I coordinate Entities saving order ?