Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named parameters not reconized in SqlQuery [DNET690] #642

Closed
firebird-automations opened this issue Aug 9, 2016 · 2 comments
Closed

Named parameters not reconized in SqlQuery [DNET690] #642

firebird-automations opened this issue Aug 9, 2016 · 2 comments

Comments

@firebird-automations
Copy link

Submitted by: Fabiano Rezende (fabiano.rezende)

try this:

using (var ctx = new FbTestModel())
{
var x = ctx.Database.SqlQuery<int>("select int_field from test where int_field = @start", 10);
var i = x.SingleOrDefault();
}

raises the error:
Must declare the variable '@start'

@firebird-automations
Copy link
Author

Commented by: @cincuranet

You should either use as parameter name @p0 or construct the parameter object explicitly.

ctx.Database.SqlQuery<int>("select int_field from test where int_field = @p0", 10);
ctx.Database.SqlQuery<int>("select int_field from test where int_field = @start", new FbParameter("@start", 10));

You can read more here https://msdn.microsoft.com/en-us/library/system.data.entity.database.sqlquery(v=vs.113).aspx#M:System.Data.Entity.Database.SqlQuery``1%28System.String,System.Object[]%29 .

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants