score:18

Accepted answer

linq is a c#/vb.net language syntax and a set of method signatures for querying data.

there are many providers for this syntax and some of them are orms. the simplest case is when you are querying collections in memory which is not an orm. there are also ways to query xml, active directory and many others which are not orms using the same syntax and the same set of methods (implemented differently).

practically every serious .net orm technology has some level of linq support

linq to sql is the first orm to support linq and it was kind of a proof of concept. it is easy to learn and lightweight but lacks a lot of features. it is still pretty decent and stack overflow used it (i'm not sure if they still use it). entity framework has linq to entities provider and it is the heavy hitter from microsoft. nhibernate has a linq provider that in my opinion barely works but they may fix it some day

there are more orms out there and most of them have some level of linq support.

score:5

linq is language intergrated query and is not an orm.
it can be used as query layer on top of an orm product like entity framework or telerik open access or nhibernate. orm is as you say object relation mapper - it does mapping between entities in the database layer to entities into your object oriented code - classes that represent the database in your application.
for further discussion see this question.

score:6

if we were to go by the wiki defiinition of the term object-relational mapping,

object-relational mapping (orm, o/rm, and o/r mapping) in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. this creates, in effect, a "virtual object database" that can be used from within the programming language. there are both free and commercial packages available that perform object-relational mapping, although some programmers opt to create their own orm tools. http://en.wikipedia.org/wiki/object-relational_mapping

then yes, linq is an orm in the sense that it is a programming technique for converting(and querying) data between incompatible systems in object-oriented programming languages, creating, in effect, a "virtual object database" that can be used from within the programming language.

score:9

is the linq orm ?

no. linq is not itself an orm.

this code uses linq to objects, which is still valid linq:

var somedata = new int[] { 5, 3, 2, 7, 4 };
var someresults = somedata
    .orderbydescending(i => i)
    .take(3)
    ;

and here is some linq to xml code:

ienumerable<xelement> partnos =
    from item in purchaseorder.descendants("item")
    where (int) item.element("quantity") *
        (decimal) item.element("usprice") > 100
    orderby (string)item.element("partnumber")
    select item;

neither of these code samples have anything to do with object relational mapping, since they don't map objects, nor do they work with relational databases.

linq has been used with some orm technologies though:

  • linq to entities allows you to access the entity framework orm with linq.
  • linq to nhibernate does the same for nhibernate.

you can find out how linq itself works by checking out this library and the associated articles. they deal with linq to objects, but will give you the basis of how linq itself works:

http://code.google.com/p/edulinq/

it will show you that linq need not have anything to do with an orm.

score:13

ok people, repeat after me:

linq is not about working with databases.

linq is an abstraction layer for working with data which allows for set based operations, projections, filters, etc on anything that can be enumerated over. it just happens to have providers for working with relational data (linq to sql, linq to datasets, linq to entities).


Related Query

More Query from same tag