I have tried the below
var p = new SqlParameter("Option", "AUTHENTICATE");
var user = _context.Set<User>().FromSqlRaw("EXECUTE dbo.spGeneral_Authenticate @Option", p).ToList();
var user = _context.Set<User>().FromSqlRaw("EXECUTE dbo.spGeneral_Authenticate @Option=@Option", p).ToList();
and
SqlParameter[] ps = new SqlParameter[1];
ps[0] = new SqlParameter("Option", "AUTHENTICATE");
var user = _context.Set<User>().FromSqlRaw("EXECUTE dbo.spGeneral_Authenticate @Option", ps).ToList();
var user = _context.Set<User>().FromSqlRaw("EXECUTE dbo.spGeneral_Authenticate @Option=@Option", ps).ToList();
Error:
InvalidCastException: The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects.
InvalidCastException: The SqlParameterCollection only accepts non-null SqlParameter type objects, not SqlParameter objects.
For the above error, SqlParameter should be Microsoft.Data.SqlClient.SqlParameter not System.Data.SqlClient.SqlParameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With