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
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.
Source: stackoverflow.com
Related Articles
- How to get table record count by passing table name as parameter using LINQ TO SQL
- LINQ Source Code Available
- How to write LINQ query with column name as parameter still in a type safe way
- Dynamic table name in linq
- LINQ Modelling Column Name Same As Table Name
- creating Linq to sqlite dbml from DbLinq source code
- ef code first: get entity table name without dataannotations
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- Dynamic "Not" by parameter in LINQ (Or any other code for that matter)
- LINQ - Accessing a column with the column name as a string parameter
- Dynamically set the table name in LINQ query
- how to get all columns name from multiple table in a dataset by LINQ
- Entity Framework query table name dynamically based on input parameter
- Make access possible to dynamic table LINQ EF6 Code First
- Get record name from a table that is referenced by ID with LINQ
- source code for LINQ 101 samples
- In linq how dynamically pass table and column name
- (Entity Framework) context.Database.SqlQuery return invalid object name for table but LINQ query works
- Run LINQ query with dynamic table name
- LINQ to Entities Table top 100 with using distinct name
- How to change a field's name in a table using linq to sql?
- Forming linq query to get table data using table name
- LINQ Group by column name passed as parameter - LINQ TO SQL
- How to reinsert data from one table onto itself using LINQ in code migration?
- How to select table name dynamically in Linq or Entity Framework
- How to join one row to every row in source table using LINQ
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- how to get the sql table name from table type in linq
- get distinct count and name using linq from dataset table
- Linq to Entities Join to Show Name in Lookup Table
- Not equal for linq operator in vb.net
- Can I Linq query into multiple variables?
- Having trouble with a many to many linq select
- ASP.NET LINQ Error Cannot create a query result of type 'System.Collections.Generic.List`1[System.Int32]'
- Getting error that "'object' does not contain a definition for 'key'" while accessing the key property in Asp.Net
- FirstOrDefault not taking argument
- Can't use ternary operator to assign Linq expression
- Retrieving associated elements based on ID in entity query
- How to perform addition in a Linq query
- How to check if one list contains all elements of another list in linq to sql statement
- Orderby() in tri-level entity structure
- C# Linq find unique item
- Linq query a string array in c# if contains either of two values?
- Select distinct ID on one table with Linq to EF5
- When I'm adding rows, I only get 1 object in database
- Building dynamic query in a loop using Expression trees
- How to pass Expression<Func<int>> to a function
- Implementing Bind() (SelectMany in LINQ) without yield (in C++)
- Using GroupBy, Count and Sum in LINQ Lambda Expressions
- VB.NET - Combine TakeWhile and SkipWhile to get both partitions