ORM Quick Survey
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
Ha, and get skewered some more for my abuse of the Reflection namespace, I think not. :laugh: All joking aside, I don't know if any of what I am working on can be considered proprietary yet but I do like to be able to build a whole new database for a specific set of data in less than half-an-hour. I can also write code like this to work with it:
DataObject dObj = dataAccess.Objects.GetDataObject("4e813bca-8fb0-448e-8f01-d714bd8132a3");
dObj["AnIntegerProperty"].SetValue(42);
dObj.Update(TransactionContext.Current);This code fetches a specific record from a database and then pushes an updated value complete with transaction logging.
if (Object.DividedByZero == true) { Universe.Implode(); }
dObj["AnIntegerProperty"].SetValue(42);
Not suggesting premature optimization, but if this
SetValue
ends up causing any bottlenecks you can do the following which works for properties but not fields because of how the values are set internally:class PropertyInfoWrapper
{
private Action _setValueDelegate;public PropertyInfoWrapper(PropertyInfo property)
{
MethodInfo delegateHelper = typeof(PropertyInfoWrapper).GetTypeInfo()
.GetMethod(nameof(this.CreateDelegate), BindingFlags.Instance | BindingFlags.NonPublic)
.MakeGenericMethod(property.DeclaringType, property.PropertyType);
_setValueDelegate = (Action)delegateHelper.Invoke(
this,
new object[] { property.SetMethod });
}private Action CreateDelegate(MethodInfo method)
{
var del = (Action)method.CreateDelegate(typeof(Action));
return (object obj, object val) => { del((TObject)obj, (TProp)val); };
}public void SetValue(object container, object value) =>
_setValueDelegate(container, value);
}I've been debating on whether to do an article about my RegexContainer[^] project for a similar reason (where this example is from). There's a lot of dislike for reflection even when it's useful.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
Rolled my own in the 90s, rerolled many times since, in 4 different languages. It seems that most devs who are using an ORM have it imposed from management! And they don't seem to be impressed. This thread will be shared with my management :laugh:
Never underestimate the power of human stupidity RAH
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
+1 for Dapper along with Dapper.Contrib. I actively avoid contracts that state EF as a requirement. I understand for some people it's the dog danglies but I can't see a compelling case to use EF. I know that's just my mileage but I genuinely would like to know why people use EF as opposed to a micro-orm like Dapper or PetaPoco.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
Rolled my own, which of course has developed over various projects. I have looked at NHibernate and EF. Found NHibernate to be badly documented to the point I couldn't (on my own, as a freelancer) actually get anything to work at all. EF was simple enough to get started with, but trying to maintain it without everything breaking was difficult. Even harder when trying to either optimise things or extend functionality. My own seems very easy to maintain/extend, but of course that's because I know every line of code having written them. I guess to an outside it might be tricky and it does require some hand-coding for each object; but it's a very mechanical process involving just 2 lines of code per d/b field, and a couple of constants.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
+1 for Dapper along with Dapper.Contrib. I actively avoid contracts that state EF as a requirement. I understand for some people it's the dog danglies but I can't see a compelling case to use EF. I know that's just my mileage but I genuinely would like to know why people use EF as opposed to a micro-orm like Dapper or PetaPoco.
-
dObj["AnIntegerProperty"].SetValue(42);
Not suggesting premature optimization, but if this
SetValue
ends up causing any bottlenecks you can do the following which works for properties but not fields because of how the values are set internally:class PropertyInfoWrapper
{
private Action _setValueDelegate;public PropertyInfoWrapper(PropertyInfo property)
{
MethodInfo delegateHelper = typeof(PropertyInfoWrapper).GetTypeInfo()
.GetMethod(nameof(this.CreateDelegate), BindingFlags.Instance | BindingFlags.NonPublic)
.MakeGenericMethod(property.DeclaringType, property.PropertyType);
_setValueDelegate = (Action)delegateHelper.Invoke(
this,
new object[] { property.SetMethod });
}private Action CreateDelegate(MethodInfo method)
{
var del = (Action)method.CreateDelegate(typeof(Action));
return (object obj, object val) => { del((TObject)obj, (TProp)val); };
}public void SetValue(object container, object value) =>
_setValueDelegate(container, value);
}I've been debating on whether to do an article about my RegexContainer[^] project for a similar reason (where this example is from). There's a lot of dislike for reflection even when it's useful.
The internals aren't really all that complex. The DataObject class only contains a collection of "Properties" that validate their own values when you try to set them. The real bottlenecks are database calls so I can build a little overhead into the classes without any real loss in performance.
Jon McKee wrote:
There's a lot of dislike for reflection even when it's useful.
I don't get this either. With Reflection, you could, in theory, write deep learning algorithms that self-optimize their own code. I approach Reflection like I do C++ code. Since both give you enough rope to hang yourself, you must weight your options and use it when your program benefits from its use or it's absolutely necessary to reach your goal.
if (Object.DividedByZero == true) { Universe.Implode(); }
-
Not using one...does that count? I'd rather avoid the abstractions and dependencies. :)
"Go forth into the source" - Neal Morse
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
I have a homegrown ORM called Postulate that is built around Dapper, with a CP article here in fact: Intro to Postulate ORM[^] This article is a bit out of date as I actively work on it here: [^] I completely agree that EF is too complicated, and in particular it's the Migrations feature I have found really painful. (In fairness, my gf uses it at work, and she has no real issue with it. I guess your mileage may vary.) I think ORM is neat area to work in, and I simply have a lot of passion for it. I've found it a really interesting challenge to balance simplicity and power. Dapper makes a lot of good things possible -- I'm a huge fan of Dapper. I admire Dapper.FastCrud (I think it's called), it's another ORM built around Dapper as the name suggests, and I sort of envy the simplicity they achieved. I do a few extra things to support code-first and some special tooling to generate database tables from model classes. I've actually never used Linq to SQL, but I hear lots of praise for it.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
-
I have a homegrown ORM called Postulate that is built around Dapper, with a CP article here in fact: Intro to Postulate ORM[^] This article is a bit out of date as I actively work on it here: [^] I completely agree that EF is too complicated, and in particular it's the Migrations feature I have found really painful. (In fairness, my gf uses it at work, and she has no real issue with it. I guess your mileage may vary.) I think ORM is neat area to work in, and I simply have a lot of passion for it. I've found it a really interesting challenge to balance simplicity and power. Dapper makes a lot of good things possible -- I'm a huge fan of Dapper. I admire Dapper.FastCrud (I think it's called), it's another ORM built around Dapper as the name suggests, and I sort of envy the simplicity they achieved. I do a few extra things to support code-first and some special tooling to generate database tables from model classes. I've actually never used Linq to SQL, but I hear lots of praise for it.
I always feel doubt when user first say "it's cool thing" and next they show WRAPPER or any other addition to the thing they name "cool". If it's so "cool", why it needs wrappers?? Really cool stuff has nothing to add/remove and it's simple to use. In this light I always recommend BLToolkit - the lib I never heard to be "wrapped", "stripped" or whatever. And it solves all my problems in one line of code almost always.
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
I too am a fan of Linq to SQL. I've taken a lot of flack for it from other developers though. The ONLY advantage I can think of for EF is that it's database agnostic, supposedly making it easier to change database engines...but I think that's an awful idea. Changing database engines is a big deal and should be treated as such!
-
I'm curious as to what ORM you use and why. For personal projects I use Linq to SQL and I love it. It's simple and works all the time. At work we're using Entity Framework and I detest it. It ALWAYS results in compilation errors and almost always generates entities wrong in some way. I'v heard of some folks here using their home rolled ORM's. For those of you, what ORM would yo say it most resembles?
If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.
Some don't seem to know the difference between an ORM and a "database engine"; and expect what is essentially a "logical entity to physical entity mapping" to behave like an SQL optimizer; and that "views", stored procs and sql pass through are now "no longer required". They also confuse "operational" versus "informational"; ORM's are more applicable to LOB than data warehousing (and denormalizing). I use EF (code first); and use it before resorting / supplementing with DDL and DML. It's not "all or nothing". EF (i.e. ORM's) can co-exisit with other access methods. As some pointed out, use ORM for CRUD (if you will); use BI for the informational; and "raw" for the rest. And "data transfer objects" are a valid pattern; and not necessarily "redundant". With consistent naming, copying can be done via reflection.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal