in my mvvm project there is one interface which contain add,update,delete interface.therefore interface is data access layer.the code for that are:
public interface IAccountDataSource
{
bool Add(Account account);
bool Update(Account account);
bool Remove(Account account);
Account GetById(int id);
Account GetByName(string name);
IEnumerable<Account> GetByCategory(AccountCategory accountCategory);
IEnumerable<Account> GetBySearchTerm(string searchTerm);
IEnumerable<Account> GetAll();
event EventHandler<ObjectAddedEventArgs> AccountAdded;
event EventHandler<ObjectUpdatedEventArgs> AccountUpdated;
event EventHandler<ObjectRemovedEventArgs> AccountRemoved;
}
enter code here
can any one say data access layer means ORM or not.?what is the advantage of data access layer?
No. What you show here is some sort of Repository. The Repository usually (but not always) talks to a ORM (the object relational mapper) which converts objects into SQL queries (or vice versa).
As to what the advantage is:
Now that you only query the database through your data access layer, you can replace the layer (by implementing/mocking its interface) by mock or stub objects for unit testing. This way you can execute your tests without actually writing something in the database, because your stub/mocks don’t actually do anything. Another advantage is that it’s easier to replace the data source by another data source (i.e. moving from relational databases to NoSQL) because all your data access code is in one place.