Gorm Golang orm associations

TownID must be specified as the foreign key. The Place struct gets like this: type Place struct { ID int Name string Description string TownID int Town Town } Now there are different approach to handle this. For example: places := []Place{} db.Find(&places) for i, _ := range places { db.Model(places[i]).Related(&places[i].Town) } This will certainly … Read more

How does Dapper compare to ADO.NET?

Dapper is just a tool. What it does is: make it trivially easy to correctly parameterize queries make it trivially easy to execute queries (scalar, multi-rows, multi-grids, and no-results) make it trivially easy to turn results into objects very efficiently and quickly What it doesn’t do is: generate a class model for you generate queries … Read more

How do I use the SQL WHERE IN construct with PetaPoco?

This will work except you can’t use the @0 (ordinal) syntax. You must use named parameters, otherwise it thinks they are individual parameters. var tagsToFind = new string[] { “SqlServer”, “IIS” }; var sql = PetaPoco.Sql.Builder.Select(“*”).From(“Tags”).Where(“Name in (@tags)”, new { tags = tagsToFind }); var result = db.Query<Tag>(sql); This will result in select * from … Read more

What exactly is the difference between a data mapper and a repository?

Suppose your application manages Person objects, with each instance having name, age and jobTitle properties. You would like to persist such objects, retrieve them from the persistence medium and maybe update (say, on their birthday, increment the age) or delete. These tasks are usually referred to as CRUD, from Create, Read, Update and Delete. It … Read more

The advantages and disadvantages of using ORM [closed]

“ORM fail to compete against SQL queries for complex queries.” Well both LINQ-SQL and Entity Framework Allow complex queries and even translation of SQL query results into objects. “Developers loose understanding of what the code is actually doing – the developer is more in control using SQL.” Not really, if you know what you are … Read more