Linq To SQL or Entity framework both integrate nicely with SQL Server 2005.
The SQL Server 2008 spec sheet promises even better integration - but I can't see it.
What are some examples of what you can do Linq-wise when talking to a 2008 server that you can't when talking to SQL Server 2005?
This marketing link claims
"Write data access code directly against a Microsoft SQL Server database, using LINQ to SQL."
Which is basically untrue.
Linq To SQL is query comprehension translated into expression trees translated into SQL, optimized by the query optimizer and then run against SQL Server database. "directly" feh.
There is a problem of paging over a joined set that SQL 2005 mis-interprets.
var orders = (
from c in Customers
from o in c.Orders
select new {c, o}
).Skip(10).Take(10).ToList();
LINQ generates a ROW_Number against the joined set. SQL2005 generates a bad plan from that code. Here's a link to the discussion.
Edit#2: I'd like to clarify that I don't know that SQL2008 solves this problem. I'm just hopeful.
it has full support for the new data types. lol. beyond that you got me, other than possibilities of optimised queries (like the merge command, etc).
I am guessing most of it has to do on the server anyways. They probably optimized the query execution as for differences I don't know except for the new types.
Unless LINQ exposes the new MERGE statement, no.
There is little effective difference in the engines especially from an ORM/client view
Related
I am new to Oracle DB. I have used SQL Management Studio extensively. I have used SQL profiler. SQL profiler lists all the queries executed whenever there is a database call. I need similar option in Oracle.
There is probably no direct equivalent. So a few things.
It's probably more effective to state what you are trying to achieve, rather that asking for a specific tool or piece of functionality
For System wide monitoring, there is Enterprise Manager (EM) and EM Express.
EM gives you access to the Automatic Workload Repository (AWR), which can provide an overall system report
For SQL specific monitoring EM gives you access to SQL*Monitor
Both AWR and SQL*Monitor can be accessed outside of EM too.
I was having a bit of trouble figuring this out so I thought I'd ask explicity...
Does oracle's ODP.Net or ODT entity framework support IQueyable - ie. If I create simple paging or query in linq will it run the query on the database?
I'm roughly aware that there are commercial products that will work with oracle to do this - I see DevArt pop up quite a bit.
Thanks,
Sam
You can use NHibernate to run LINQ queries against Oracle database.
NHibernate uses it's "language" called HQL to talk to various databases. And they also built LINQ provider that creates HQL that is in the second phase sent to target DB.
After a bit more searching, it appears the ODP.Net will convert queries into SQL code, but ... poorly on occasion?
see
https://community.oracle.com/thread/2598619
for details & more relevant resources see
https://community.oracle.com/community/developer/english/oracle_database/windows_and_.net/odp.net/content
& enter tag "paging"
According to the last comment in the thread https://community.oracle.com/thread/2349719, linq actully generates the SQL.. interesting
So I am pretty new to EntityFramework, actualy in the POC stage right now, and one of the questions I am trying to answer is how can I visualize the query generated by EF through the debugger or other process attachable tool?
The case I am trying to solve is while trying to debug a QA, or production issue, the developer needs to be able to attach to the process through the remote debugger, and needs to visualize the query created by EF to see if it's framed in the most effective manner.
The same can be said during development, where I need to be able to visualize the query made by EF.
You can either:
Use Sql Server Management Studio Query Analyzer to see the traffic that goes to the database (probably the least invasive)
Attach VS to your process and use IntelliTrace is should show commands sent to the database
Try using EF Tracing provider (http://code.msdn.microsoft.com/EFProviderWrappers)
For queries you can do .ToTraceString() on ObjectQuery object and .ToString() on DbQuery object when debugging.
EDIT
EF6 contains a new feature that allows you log the traffic to the database
How I can write database independent, data layer using Linq to Sql? For example I have one dbml file, which I can use with almost any database at runtime ( by specifying web.config)
Entity framwork is a better option, but it is not implemented in Mono so I can't use it.
Edit: I mean different databases like Sql Server, Mysql or SqlLite. I prefer to use DbLinq for other databases.
Edit 2 :
I have created Linq to Sql mapping class by following this blog post.
http://blogs.msdn.com/b/spike/archive/2010/01/08/how-to-use-linq-to-sql-without-using-the-designer-generated-classes.aspx
Now how I can use this with other databases.
You need a 3rd party linq provider like ALinq http://www.alinq.org/ that suports Mono.
As it is structured from Microsoft, Linq to SQL is VERY database dependent, ie it only works with MS SQL. I believe that ALinq does work on mono. Here's a better list of 3rd party providers:
http://blog.linqexchange.com/index.php/links-to-linq-providers/
I have a Desktop application that uses Linq To SQL as the DAL. It accesses a local SQL Express DB.
If I have a SQL CE DB that has the Exact same schema(table structure) can I re-use the generated dbml with just giving it a different connection string?
This article on LINQ To SQL on SQL CE from Matt Manela suggests that you could replace your SQL Server Express connection string with a connection string to SQL Server CE without any large issues. If it's just table-level querying that you're interested in, it sounds like you'll be in good shape.
He points out though, that CE handles connections differently than the larger SQL Server editions.
Without having tested it myself, I'd only want to determine if LINQ To SQL would ever generate any TSQL statements using keywords or features that SQL CE didn't support.
Also note, the current release does not support stored procedures or the XML datatype. It uses a subset of TSQL.
Best to visit the official .NET 3.5 SP1 LINQ To SQL for SQL Server Compact page at Microsoft.