For example:
I have a class
MyClass //Dirty code
{
public int Id;
public string Name;
}
And I have a table in DB with Id and Name fields.
Can I bind ObservableCollection of MyClass objects to this DB table and how to do this?
Also I want to make changes in ObservableCollection and changes must be mirrored in DB.
A database does not automatically update your application if data changes and neither will it write back to the database if your application changes a value. The most basic approach to achieve what you are after would be to poll the server to check for changes at set intervals and update the screen from there.
If you are using SQL Server you could look into CDC which would help identify what has changed if anything. None of this is automatic though and you will need to re-run your query each time and do the reverse to write back.
I assume you are using WPF / Silverlight so something like this could be used: