score:0
I guess the error related somehow to T-SQL Table Variables.
@-quoted string literals start with @ and are enclosed in double quotation marks. For example:
@"good morning" // a string literal
The advantage of @-quoting is that escape sequences are not processed, which makes it easy to write, for example, a fully qualified file name:
@"c:\Docs\Source\a.txt" // rather than "c:\\Docs\\Source\\a.txt"
To include a double quotation mark in an @-quoted string, double it:
@"""Ahoy!"" cried the captain." // "Ahoy!" cried the captain.
Another use of the @ symbol is to use referenced (/reference) identifiers that happen to be C# keywords. For more information, see 2.4.2 Identifiers.
score:0
This isn't quite and answer, more a confirmation that it isn't anything to do with @"" strings, but it seems to be a limitation of the Parameter substitution in ExecuteSqlCommand and SqlQuery.
I have the same problem as you and found that you cannot provide the table name as a parameter. I have a command that is of the form:
Context.Database.ExecuteSqlCommand(@"Delete From MyTable WHERE MyColumn = {0}", someValue);
That works fine, but if I try to provide MyTable as a parameter it fails.
If you think about it the table name doesn't really fit as a parameter so it makes sense that it rejects it. However I agree with you that the error message is really not that helpful.
score:3
@ before the "" says to compiler that this is a string nothing else
Read it here http://msdn.microsoft.com/en-us/library/362314fe(v=vs.71).aspx
Must declare the table variable "@p0"
seems to be different
Edited
: Dont use table name as a parameter better use your table name only,it will cause sql injection please read
Source: stackoverflow.com
Related Query
- How to get table record count by passing table name as parameter using LINQ TO SQL
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- LINQ to SQL - Why can't you use a WHERE after an ORDER BY?
- Why can't I use a range value's property as a parameter when calling a method in a LINQ query?
- Why does "linq to sql classes" change the name of a table when making a class?
- LINQ-to-SQL: Why can't I use table name as parameter?
- LINQ Group by column name passed as parameter - LINQ TO SQL
- how to get the sql table name from table type in linq
- how to translate a linq expression into sql string use c# code
- Convert table name (in string) to use it in the LINQ query : C#, Entity Framework
- How to pass table name dynamically in linq to sql
- Instantiate empty IQueryable for use with Linq to sql
- How are people unit testing code that uses Linq to SQL
- Why do people use linq to sql?
- Why use LINQ Join on a simple one-many relationship?
- Why I lose performance if I use LINQ on MongoDB?
- Why use "select new " in LINQ
- Linq error generic parameter or the query must use a nullable type
- LINQ to SQL Every Nth Row From Table
- Why would Entity Framework not be able to use ToString() in a LINQ statement?
- How to add field not mapped to table in Linq to Sql
- Why didn't the LINQ designers stick with using the way sql is written today?
- Why do I need Stored Procedures when I have LINQ to SQL
- Can I use C# string interpolation with Linq to SQL
- How to use distinct with group by in Linq to SQL
- Deleting rows in a table with Linq to SQL
- Use contains in LINQ to SQL join
- LINQ to SQL entity column name attribute ignored with guid primary key
- Why does LINQ to SQL translate GroupBy into multiple queries
- Use SQL LIKE operator in C# LINQ
More Query from same tag
- How Can I get executable sql statement from linq or IQueryable object?
- Sort by most occurring string from json by key order and order contains array itself
- Multi-level grouping in LINQ?
- Navigational Property not materialized in Linq Query Syntax also Lazy Loading didnt work
- Dynamic LINQ expression for Select with child collection (Entity Framework)
- ASP.NET MVC 3 Linq uppercase or lowercase database search
- Group by using inner property in a list using Lambda expression
- Need help merging two LINQ statements
- Creating a new table from grouped substring of existing table
- No Overload for 'MouseDoubleClick method' matches delegate 'System.Windows.Input.MouseButtonEventHandler'
- Linq Grouping and averages
- LINQ to DataSet, DataTable.AsEnumerable() not recognized
- How to find the max-ID by using a lambda-query?
- How to group the same values in a sequence with LINQ?
- Adding another table to a grouped linq query
- Using LINQ to compare 2 lists of objects for updated properties
- Select Top n from XML File
- How to dynamically order by certain entity properties in Entity Framework 7 (Core)
- Linq: {"Operation could destabilize the runtime."}
- get string array from another delimited string array
- getting a type mismatch/cast error I don't understand when using array Concat
- Sorting output from Linq with group by
- How to do calculation within Linq select block?
- Linq ToList() fails to trigger Immediate Execution
- Parsing XML through to CSV in C# using linq
- How to refactor repeated code using reflection
- distinct value from a column in a grid using linq
- LINQ Like Clause - Without Wildcard operator
- LINQ - search between IList and list of strings
- Is there an accepted name for this type of enumerable operation?