I've been playing with Dapper, trying to see if it's a good light-weight alternative to Entity Framework. So far I've been impressed with it's ability to quickly pull an entity <model>
from a DB and get it into an IEnumerable of a model, or just create a single instance of a model. Very slick.
But what I'm not seeing is an easy way to update that model back to the db.
Example:
public class Dog
{
public Guid Id { get; set; }
public int? Age { get; set; }
public string Name { get; set; }
public float? Weight { get; set; }
}
We can easily create an IEnumerable of Dog as follows:
IEnumerable<Dog> dogs = connection.Query<Dog>("SELECT * FROM Dog")
Or, for a single instance:
Dog dog = connection.Query<Dog>("SELECT * FROM Dog WHERE DogId = @dogid")
That all works great. But now, if we make changes to "dog" (say, just change it's weight), is there a slick, fast, easy way to get that entity back into the database without having to do a manual UPDATE query, listing out each field?
Thanks!