I’m working on a project that requires that I take data from an XML API that I don’t control and insert that data into a database (I control) for consumption by a different application (I control but …
Tag: c#
How to make lookup field work in this case without defining the foreign key in the database?
The code is as follows (database first): C# code: UserTypeId is mapped, UserType is not. Any ideas how to make it work? Answer If we consider this as one to many relationship. Then Mapping using dataanotation will be like this. And to query
Parameters in ASP.NET MVC to create a PDF
I have a particular problem, I am working with ASP.NET MVC in C# and SQL Server. The idea is that on the main screen you see a text box and a button, entering a number that brings us our data. By bringing that data, the person can choose whether they want to see if that data in a PDF. But,
Converting a C# SQL string into a SQL stored procedure
In my C# code I have the following piece of code that I am looking at converting into SQL in a stored procedure: StringBuilder sql = new StringBuilder(“SELECT * FROM MyDatabase WHERE 1 = 1”); if (!…
How to alias column into another operation
I want to use the Elias column startdate into anthor operation to calculate Answer Use CROSS APPLY to define the alias in the FROM clause. Then it is available throughout the query: Note that I added table aliases so the query is easier to write and read.
How to get names of columns from table (Microsoft SQL Server)?
I need to get names of columns and save them in strings. SQL statement works correctly (I checked it in SQL manager). Answer After exec() use queryTem.next() which retrieves next record in the result until theres any record. And use QVector to store column name. Read more here about QVector.
Find turning points in rows with SQL or LINQ
Lest say I have the following data: Date Value 04.04.2019 | -1,7 05.04.2019 | -3,3 06.04.2019 | -4,4 07.04.2019 | -6,4 08.04.2019 | 5 11.04.2019 …
Entity Framework – Left outer join on multiple columns with OR condition
Is it possible to write lambda left join on multiple columns that would generate OR condition instead of AND? This will generate following query I would like to get the same query but instead of AND condition I want it to be OR: Is there a way to achieve this? EDIT: version – EF 6.2.0 Answer LINQ join operators (Join,
Member’s books in possession in Library System
Hello I am currently working into a library system and I do want to view how many books are in possession of a specific member. I want to add a copies to student whenever I issue a book to them. I have tried: but it doesn’t insert into members row, instead it shows I have also tried: But doesn’t work
Selecting 7th Person (row) and get 7 as result
I want to select the 7th person (Pierre Gasly (for example)) Score list Season F1, so I can return number 7 in my C# application. SELECT CONCAT(strVoorNaam, strTussenVoegsel, ‘ ‘, strAchterNaam) AS …