Show Entity Framework generated SQL for Insert / Update - c#

Is it possible, from code, to see the generated SQL for an insert/update ?
I need it by code because I am using a database that does not permit to show SQL queries.

Get a demo of the entity framework profiler
Entity Framework Profiler
http://efprof.com/
Maybe this might be of help..
http://blog.cincura.net/227674-how-to-show-sql-command-created-by-entity-framework/
This question may well help you as well...
Best way to show the SQL trace of a LINQ query to Entity Framework 3.5

Related

From TypeDataset to Entity framework

I am working on window application developed using SCSF and we are using sybase database. As practise we create typedataset in the .net project and then populate them using framework method and for all the sql statement we write stored procedure in the database.
So we have type dataset in memory so I am using linq to select records from datatable. Can I step one step further and use something related to Entity Framework?
Can it reduce my work? I don't have hands-on experience with Entity Framework but can you suggest something in this scenario?
Thanks,
Denish
Entity framework uses similar concepts as the type datasets except for:
The ability to have a class structure that is not exactly the same as the table structure (e.g. class hierarchy, splitting tables into multiple classes, joining tables into one class).
The ability to use LINQ to perform queries in the database instead of in memory.
Entity framework also lets you map results of stored procedures to classes and bring results into memory if you need to run a query that is faster in memory or not translatable to SQL.
For most SQL queries the LINQ to Entity will be effective enough, so you will probably end up writing less stored procedures.
You will have to learn how to use EF and LINQ effectively and use can use 3rd party tools such as Entity Framework Profiler to help you.

How do I debug/profile for performance when using Entity Framework 4.1

I just got a request to speed up a single request in an application. I traced the bottleneck back to the Data Access Layer where I am using Entity Framework.
I am new to EF, it seems to have worked ok so far.
My question is: what tools/process should I use to debug this performance problem?
Additionally to database profilers you can check very good article about the most popular tools available to tune entity framework.
Personally I use SQL Profiler to profile the LINQ to Entity Query generated for SQL Server. Then I determine the issue in SQL. AND from this I can understand if I need indices, or need to rewrite the LINQ to Entity Query.
If you're not using the Entity Framework Profiler, you're really missing out. The cost is negligible for the insight it provides.
http://efprof.com/

LINQ To Entities then SQLCompact

). I hope somebody wants some easy reputation by answering a simple question ::- ). How are you? Ok... joking ::- D.
The question is about how LINQ to Entities works with SQL Compact.
First of all, is there any way to profile stuff sent to an SQL Compact database? Apparently the Microsoft SQL Server Profiler does not work on SQL Compact databases... well... that's to be expected. But is there any other way to see the SQL query resulting from a LINQ select? Specifically:
IQueryable<some_table> query = from v in SomeEntity.some_table select v;
I am using some extension methods I found via Google to apply a "where" to the above select. Normally in Entity Framework you can't do that with LINQ (in .Net 3.5) but there are some workarounds.
What I want to do is verify if the workarounds get ALL the data from the table and then cheaply filter it, or if they are doing the RIGHT THING and only get the data that I asked for.
Secondly, do you know for sure that the statement below does NOT bring all the data in the table and puts it in memory after which does a cheap filter on it? (gosh I'd like a profiler to see what that dude is doing over there in the back-stage).
from v in SomeEntity.some_table where v.some_column == some_int_value select v;
I'll give you 2 answers: first, check out this link: How do I view the SQL generated by the Entity Framework?
Second, have a look at EF Prof.

can LINQ being used with Sybase database?

Customer wants to move from SQL server to Sybase database. Don't know if LINQ can still be here? change is big?
The following article states that Sybase provide support for SQL Anywhere through the Entity Framework.

How do you use LINQ with Sqlite

Would someone explain how to get LINQ working with Sqlite.
Here you have an SQL Linq provider for SQLite, and some other DBs
Joe Albahari's LINQPad now supports Sqlite: http://www.linqpad.net/Beta.aspx. The one LINQ tool to rule them all.
The link provided by CMS doesn't work anymore. I have used this one as it now seems to be baked into their SQL lite ADO .NET provider.
Unfortunately they still don't support the designer mode of VS for creating classes :(
Also be aware that SQL Server compact doesn't support the design mode for LINQ classes! However if you want to use the entity framework the designer does work for SQL lite and SQL Server compact :)
Yup there is a SqlLite Linq Provider as mentioned by CMS
Check out SQL server compact and it works well with Linq
There is another thread on SO which you should check
I would like to add that you can use Linq to Sql with SqlLite with a couple of stipulations:
You cannot use the Linq to Sql designer which means you have to hand roll your classes.
You have to be careful not to do certain operation which will result in Sql code which is not supported by SqlLite.
For example, you cannot use FirstOrDefault() in any of your Linq queries because it will result in something like:
select top 1 * from table where ...
Since SqlLite doesn't support the "top 1" syntax, you will gt a runtime Sql error.
Other than that, I have been using Linq to Sql with SqlLite with great success for basic CRUD operations.
You can use this: http://code.google.com/p/dblinq2007.
Although it looks like the project is still in Alpha stage, IMO it is actually very stable now. Of course if you have a huge project, it is better to consider using something else like MySQL or SQL Compact. I don't like SQL Server, because it is too bloated, and offers not many more functionalities over SQL Compact or MySQL
Check this provider:
SqlLite Linq Provider
Also you can consider using SQL Compact which has very good LINQ-to-SQL support.
On this time there is NO good tools to do this!
LINQ providers for SQLite all is in alpha stage (for example:dblinq2007). And it is very big risk to use it in commercial purpose! So maybe in future...
If you want ot use ADO.NET there is good ove: phxsoftware.

Categories

Resources