Using DLinq as SQL builder

  • Thread starter Thread starter Andrus
  • Start date Start date
A

Andrus

I need to pass DLinq query to RDLDEsigner.
RDLDesigner does not accept IQueryable<T>.
It accepts SQL select statement in plain text format as data source.

How to get SELECT statement which corresponds to dlinq query
as plain text as it is being sent to server ?

How to create method which allows to grab the sql statement which is being
passed to DataReader without executing DataReader and opening connection.

Something like

Northwind.Customers.Select().GetCommandText()


Andrus.
 
Marc,
For LINQ-to-SQL, GetCommand() on the data-context.

Thank you.
I havent found any information how it handles parameters and don't have MS
SQL installed.

Will it return parameters replaced with values or show placeholders instead
of parameter values ?

Andrus.
 
placeholders; for example:

C#:

string s = "abc";
var qry = ctx.Customers
.Where(x => x.Address == s)
.OrderBy(x => ctx.Random());

TSQL (note @p0):

SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName],
[t0].[ContactT
itle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode],
[t0].[Coun
try], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE [t0].[Address] = @p0
ORDER BY NEWID()

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top