I have got this SQL statement which I am trying to convert to LINQ. I have not been able to do the IN part. Tried following but I am unable to complete it: How do I write IN part of SQL in LINQ? Answer You can use Contains:
Tag: .net
How to export data to already existing excel sheet in C#?
I know how to create a new excel and export data into it. But how can I export data to an already existing excel which have some formats and data validation? Answer Take a look to NuGet library ClosedXML . I used it in the past and it’s really straightforward. Install the package in your solution: from VS: Tools >
Why Is My API Not Returning Nested Object (.NET 6 Entity Framework and SQL DB)
I have created an API, using EF and database first approach via scaffolding. I have the following in my context file and then the following in my models Request: Request Line: My Request controller looks like this: In Swagger, it is displayed correctly in the example, based on the model: But when running the GET, what I am actually seeing
Write a SQL query with a subquery in .NET Core using Entity Framework that returns a list of items with varying number of returned child rows
I have this test SqlFiddle: http://sqlfiddle.com/#!18/05fce/1 The idea is that for each product (table webspiderproduct) it will return the lowest price from each shopId from the table webspiderproductprice. So the returned data should look like this: I am using SQL Server. In pseudocode should I write a and then do a foreach through each row using linq and then add
“Buy Items” with SQL Transaction in EF Core, if user send many requests, items are bought even if they can’t afford it
I’m trying to make a game where the user can buy items with ingame coins. The coins and the items are stored in a SQL database, and user should (obviously) only be able to buy items that they can afford. The Problem with this code is that if the user spams many requests at the same time, he gets more
Search SQL database with multiple filters
I have the following code: This gives me the rows where “category_id” is equal to the 1. I now want the SELECT statement to return rows where the “category_id” is equal to one of the values I give it. So a simple SELECT statement would look something like this The problem is that I wouldn’t know the values to search
How do I translate this specifik SQL statement to LINQ
SQL: C# Objects: Monitor: And Counter: And the objects that I need to turn it into is: AllStatistics: I don’t have much experience with LINQ so the most I’ve achieved with it is somethig like: My question is, how would I compose an LINQ statement with the same functionality of the above SQL query ? Answer It looks like you
Email address lookup in SQL Server
We have a large subscriber database and have a lookup based on email address of type nvarchar(100). It sometimes times out probably because of a large scan of it. I want to improve this, but weary of some of the options. Would an index on it be ok, I can handle the additional storage if needed, or a computed column
I’m getting the OleDb exception ‘Unspecified error the scale is Invalid’ when trying to use a stored procedure
I made a stored procedure in SQLExpress to insert information in both the Header and Details table. I’ve ran the stored procedure in SQL Server Management Studio to make sure it works fine. But when I try to use the stored procedure using TableAdapters in visual studio it gives me the error: System.Data.OleDb.OleDbException: ‘Unspecified error The scale is invalid.’ Here
Is is possible to create a view based on a table in a different server?
My client have an azure service app MyServiceApp, its database called MyCloudServer (its data is taken from a legacy MyPremiseServer). The MyPremiseServer is a server located on my client’s site, because the cloud’s service app MyServiceApp can’t access it, They created the MyCloudServer with the exact same scheme of MyPremiseServer. In order to make the MyCloudServer to hold the same