Doctrine 2 ArrayCollection filter method

Doctrine now has Criteria which offers a single API for filtering collections with SQL and in PHP, depending on the context. Update This will achieve the result in the accepted answer, without getting everything from the database. use Doctrine\Common\Collections\Criteria; /** * @ORM\Entity */ class Member { // … public function getCommentsFiltered($ids) { $criteria = … Read more

Dapper.Rainbow VS Dapper.Contrib

I’ve been using Dapper for a while now and have wondered what the Contrib and Rainbow projects were all about myself. After a bit of code review, here are my thoughts on their uses: Dapper.Contrib Contrib provides a set of extension methods on the IDbConnection interface for basic CRUD operations: Get Insert Update Delete The … Read more

What are the advantages of using an ORM? [closed]

I’d say that if you aren’t dealing with objects there’s little point in using an ORM. If your relational tables/columns map 1:1 with objects/attributes, there’s not much point in using an ORM. If your objects don’t have any 1:1, 1:m or m:n relationships with other objects, there’s not much point in using an ORM. If … Read more

How do I map lists of nested objects with Dapper

Alternatively, you can use one query with a lookup: var lookup = new Dictionary<int, Course>(); conn.Query<Course, Location, Course>(@” SELECT c.*, l.* FROM Course c INNER JOIN Location l ON c.LocationId = l.Id “, (c, l) => { Course course; if (!lookup.TryGetValue(c.Id, out course)) lookup.Add(c.Id, course = c); if (course.Locations == null) course.Locations = new List<Location>(); … Read more