I have this stored procedure which I call from C# using Entity Framework Core using a DbContext When I call the SP from code, the output parameters are empty. How to get the output parameter values in code? When I call the SP directly from SQL the output parameters are populated correctly. Answer You’re missing the OUTPUT keyword when building
Tag: c#
Override query in sql string possible? C#
Currently I’m working with my local MSSQL database and when I make a connection all works good. However that is not the question I’m having right now; I want to make my code cleaner and I don’t want to have duplicated code or almost duplicated code. For now I’m working with one large class that holds all the methods to
Join multiple columns from the same table using Linq
I would like to convert following sql query into Linq to SQL going through this I have so far tried following which didn’t work out Edit: following query is being generated against Svyatoslav Danyliv answer which is returning 7 rows instead of 6 Answer Join which contains not just AND expressions is possible via from x in entities.Where(x => ..).
Is it possible to sum up time field in SQL Server?
I have 3 time(0) column in 1 row. I want to calculate arrival-Time column automatically and this is result of the sum of Departure-Time + Duration is it possible with trigger or computed area method? thanks in advance Answer SQL Server does not support direct addition on time values; however, you can use datediff against 0 to find how many
How to map from query string to SQL query? [closed]
So I have as search endpoint [HttpGet(“search”)] public async Task Search([FromQuery] string query) that returns a list of users from the cosmosDb based on email, name …
Polly retry policy with sql holding transaction open
I am using Polly to implement a retry policy for transient SQL errors. The issue is I need to wrap my db calls up in a transaction (because if any one fails, I want to rollback). This was easy before I implemented retry from Polly because I would just catch the exception and rollback. However, I am now using the
Selecting multiple columns for updating in Linq
I have a products table which contains thousands of products. I want to update only two columns (price, isAvailable) of this table. So is there is a way to select only those two columns from this table? This is the code that I am using. But I don’t want to select all columns. I have tried this But this is
‘Procedure Has Too Many Arguments’ Error Although I Have Only Two
I checked the other posts related to this problem but could not find any answers. I have a post action method for my hotel api and in the Hotel Repository I have this CreateHotel method below. I just enter two arguments and there’s two arguments in the stored procedure too but I get this error: System.Data.SqlClient.SqlException (0x80131904): Procedure or function
PostgreSql and EF – Getting ‘duplicate key’ error while doing ‘ToDictionary’ after grouping
Here is my query. UserName column is citext, having non-unique index on it. var logs = Db.Logs .GroupBy(x => x.UserName) .ToDictionary(g => g.Key, g => g.Max(m => m….
Is there a way to return 0 if values does not exist in table using SQL Server
I have put down below a query to retrieve from four tables which are Query: The query is working well but if the Expense table has no values Expense.Invoice_No does not match with Sales_Invoice.Invoice_No, then the query above will return empty rows. But what I wish to do is that, if Expense.Invoice_No does not exists then I still want to