Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run a SQL query in C# statement/program with Linqpad?

Tags:

c#

linqpad

How can I run a SQL query in C# statement or C# program with Linqpad?

Yes I have to mix SQL statements with Linq for compatibility reason. I use linqpad with postgres driver and these driver doesn't recognize the hstore of postgres. I already knows I can get these ignored column by using classic SQL.

like image 389
Bastien Vandamme Avatar asked Aug 16 '17 07:08

Bastien Vandamme


People also ask

Can you use SQL in C?

You can code SQL statements in a C or C++ program wherever you can use executable statements. Each SQL statement in a C or C++ program must begin with EXEC SQL and end with a semicolon (;). The EXEC and SQL keywords must appear on one line, but the remainder of the statement can appear on subsequent lines.

What is SQL in C language?

Structured Query Language (SQL) is the language used in relational database management systems (RDBMS) to query, update, and delete data. SQL is a standard query language for RDBMS. SQL language's queries are also known as SQL commands or SQL statements.


1 Answers

You can use the ExecuteCommand on LinqPad to run SQL statements direct on C# Statement. You can execute SQL statements with parameters formatting command string with {0}, {1}, etc.

ExecuteCommand("DELETE FROM TableOne where PrimaryKey = {0}", primaryKey);

ExecuteCommand

like image 97
Hugo Dantas Avatar answered Sep 28 '22 06:09

Hugo Dantas