I played with Dapper trying to figure out if this is a good lightweight alternative to the Entity Framework. So far, I was impressed with the ability to quickly derive the <model>
entity from the database and retrieve it in an IEnumerable model, or simply create one instance of the model. Very smooth.
But what I don't see is an easy way to upgrade this model to 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 IEnumerable from Dog as follows:
IEnumerable<Dog> dogs = connection.Query<Dog>("SELECT * FROM Dog")
Or, for one instance:
Dog dog = connection.Query<Dog>("SELECT * FROM Dog WHERE DogId = @dogid")
Everything works great. But now, if we make changes to the “dog” (say, just change its weight), is there a spot, a quick and easy way to return this entity to the database without having to perform a manual UPDATE query, listing each field
Thanks!
source share