THESE FORUMS ARE NOW FROZEN
Please choose "Forums" from the Main menu of www.entityspaces.net to get to our new forums.

IsDirty method

rated by 0 users
This post has 3 Replies | 1 Follower

Top 200 Contributor
Posts 14
howcool Posted: 09-16-2009 1:25 AM

From the application, when certain field has made changes and binding will trigger the changes and will inform user to save changes. But my problem is when certain field in the database is non-visible object field to the form and I have to trigger its changes everytime I call OrdersCollection.Save() method.

Instead the application execute the following SQL command when I have made changes of "ShipName" to another new name in data binding.

Code:
UPDATE Orders
SET ShipName=@ShipName WHERE CustomerID='VINET' and OrderID='10248'

I need the application execute the actual SQL command was

Code:
UPDATE Orders
SET ShipName=@ShipName, RequiredDate='dd/mm/yyyy' WHERE CustomerID='VINET' and OrderID='10248'

Everytime I update any fields in Orders table, it will trigger the RequiredDate fields as changes fields as well but RequiredDate does not bind to any controls. How do I do it through coding using ES collection?

Top 10 Contributor
Posts 905

It sounds like what you are wanting to do is override .Save and add your own values. If so see these threads

http://community.entityspaces.net/forums/thread/15331.aspx

http://community.entityspaces.net/forums/thread/15254.aspx

 

Regards, Scott Schecter EntitySpaces | Blog | Twitter

Top 200 Contributor
Posts 14

If I override the Save() method at Entity, how do I interactively set certain fields to a specified value from the ES collection since if I called ES collection Save() method will not trigger the method at Entity class. Any idea on how to trigger Entity's Save() method from ES collection?

Code:
public partial class Orders : esOrders
{
        public override void Save()
        {
            if (!es.IsDeleted)
            {
                this.LastModified = DateTime.Now;
            }
            base.Save();
        }
}
Top 10 Contributor
Posts 3,881

I realize this is maybe more cumbersome that you want but you might try this?

Code:
public partial class EmployeesCollection : esEmployeesCollection
{
    public override void Save()
    {
        foreach(Employees emp in this)
        {
            if (emp.es.RowState == DataRowState.Modified)
            {
                this.LastModified = DateTime.Now;
            }
        }

        base.Save();
    }
}

EntitySpaces | Twitter | BLOG | Please honor our Software License

Page 1 of 1 (4 items) | RSS
Copyright © 2005 - 2009, EntitySpaces, LLC