LINQ to SQL performs a number of tricks. If your own ORM uses reflection, you need to cache it, but I suspect that the difference may be that you are not caching ordinals.
eg. instead
while(dataReader.Read()) { ... myNewObj.SomeProperty = dataReader.GetInt32(dataReader.GetOrdinal("SomeField")); ... }
create a variable for each ordinal and refer to it inside your loop:
var someFieldIdx = dataReader.GetOrdinal("SomeField"); ... while(dataReader.Read()) { ... myNewObj.SomeProperty = dataReader.GetInt32(someFieldIdx); ... }
It would be even better to cache them on some static variables.
If you are already doing this, you may want to publish part of your ORM code that creates the objects.
source share