How does the Linq to SQL works? - linq-to-sql

I use Linq to SQL in my project. I fetch data from a SQL Stored procedure using it. It works perfectly, but I dont understand exactly how does LINQ SQL communicates with SQL server internally, where does it stores the data after fetching it? From where it gets the connection string?
Thanks in advance..

better to read: http://msdn.microsoft.com/en-us/library/bb425822.aspx

Related

MySQL Stored Procedure SQL Injection

I'm coming from an Oracle world where I can use DBMS_SQL for dynamic SQL with an unknown number of bind variables. Apparently this is not possible in MySQL. So my question is how do you protect against SQL Injection in MySQL? I thought this would be easy to lookup but every example I find is with PHP & MySQL. I'm only dealing with MySQL stored procedures, no PHP. Here is a snippet:
set #sql_string=concat(#sql_string,'col1=''',someRandomText,''' where col2=''',moreRandomText,''';');
Is there a protection function that could be applied to someRandomText to prevent SQL Injection (http://bobby-tables.com/)?
Thanks!

how can I get data from database in mysql in node js without using direct queries?

All of the examples I've found show how to use query by sql statement, as: 'connection.query("select * from my_table",...)', but I want to do it without sql statement, but with store procedure.
I found something about 'db-mysql' that supplies this option but I didn't success installing it.
I don't want to use sql statement in my code.
I want to select, update etc. by stored procedures in my mysqldatabase (like C#).
How can I do it?
Checkout http://sequelizejs.com/ it is a node compatible orm which allows you to easily interface with sql without needing to use sql statements.

Creating a general hibernate query that works with the LEN or LENGTH function

In one of my database services, I create a hibernate query as follows:
createSQLQuery("SELECT * FROM documentheaders order by LEN(header) DESC").addEntity(Documentheaders.class);
This works great as long as I am using MS SQL. If I try to run this query with MYSQL I get a sql error because in MYSQL, the correct function is LENGTH. Is there any way to create a single sql query that will cover both dialects (I know I can check the database type and use separate queries for each kind of database but I'm hoping for something more elegant.
Thanks,
Elliott
My thanks to frictionlesspulley for alerting me to the HQL function. That solved the problem.

How can I query XML data in SSRS / VS 2008?

I have a report query using a lot of WITH XMLNAMESPACES to query some XML data in SQL Server 2008. It doesn't look like i can create a report in VS 2008 using this query because of the xml querying. If I'm reading MS's whitepaper correctly, you have to pull the XML out and then do a separate query against it? Anyone have any experience with this, or is there a better way?
And this is an issue of misinterpreting errors. The real issue in my query wasn't the use of WITH XMLNAMESPACES, but the use of "sql:variable("#varName") in the WHERE of my XSL. Easy way to solve that is to add a DECLARE #varName in the query and set it to the passed in parameter. After that, it worked like a champ.

My Linq to SQL query paging logic is not executing in the database

How can I make my Linq to SQL query logic execute on the server?
I have a created a Linq query and returned it as an IEnumerable. Subsequent operations on the query such as .Count() or .Take(5) are evaluated on the client in CLR, rather than on the server.
Converting to IEnumerable will cause the query to be executed - as a result the data is now on the client side.
If you want to execute paging on the server side, you should perform those operations while it is still a late executing IQueryable.
IEnumerable was the problem. Returning the Linq.DataQuery as an IQueryable allows Linq to SQL to add additional operations to the query. Figured this out as I was describing the problem.