In entity framework core, how we can set relationship for a table, when two fields is mapping to primary key of the another table. For example I have two table namely Users & CashBox. Users Table Field Value UserId int UserName string CashBox Table Field Value CashBoxId int ActivatedBy int DeactivatedBy int In this case, activatedby & deactivatedby has to
Tag: asp.net-core
RawSQL and auto-generated keys in EF Core 3.1
I have a Model with a Guid primary key. I want the Database to generate a key on insert so I added the following annotations: Now I expected that inserts with RawSQL wouldn’t expect a primary key, however the folllowing statement doesn’t work when executred through ExecuteSqlRaw: An error is caused by the DB about a non-nullable primary key. Explicitly
Dapper stopped pulling joined table after updating the table with a stored procedure
Because I was having this error InnerException = {“Cannot insert explicit value for identity column in table ‘Loan’ when IDENTITY_INSERT is set to OFF.”} So I decided to change it to this stored procedure. Which is inserting the record successfully, after inserting the page will redirect to the index page and call another method to pull the list and display
How to map/join two tables and filter by parameters using dapper
I want to join two tables that have a relationship with each other, In the Customer table, there are two columns for deleted and approved. Get the Customer that are approved and not deleted then match the Customer with the Loan table Using CustId (Both Tables has CustId) and Filter by supplied parameters Deleted=0 Approved=1 Passed Parameters are(And they can
Use inputbox to filter in asp.net core razor with dapper
I have a query that is already getting data from the DB, Now I want to filter the data using a checkbox from the razor page. Below here is the checkbox I am already getting the values of the checkboxes via string[] Requestloans But the problem is how to filer db with the RequestLoans array using dapper. If this is
Data is retrieved but is not getting saved or updated ASP.NET Core 3.1
My questions is similar to this question but I’ve applied the answers and it’s still not working and I’ve used a slightly different approach while storing the data in the DB. Employee Model Class Type script code related to saving Save button View code Controller code related to Save When I click on save button it reloads the page without
How to replace columns in a Queryable in a generic fashion without executing the Queryable
As an example, I have a Product entity, a ProductViewModel and a Label entity. Two of my product properties correspond to a label code rather than an actual value. So for example a Product’s Name is “…
Can’t save multiple selections in select list – asp.net core web app razor pages
Here I am able to bind the multi-select select list on the create page. The biggest problem I’m having is that I am trying to edit/post values and there’s no direct field to bind to in my model. I have found a good example here, but it only shows you how to save 1 selection. https://www.learnrazorpages.com/razor-pages/forms/select-lists My SecurityLog Model has
SQL Server – Close external port and work as localhost when sql server and application are on the same server
My database and my web application are at the same server at the moment and I would like to access SQL Server as localhost and close the SQL Server port for remote connections. This is my current …
DbContext.DbSet.FromSql() not accepting parameters
I have a database with two tables, and wrote a relatively simple select statement that combines the data and returns me the fields I want. In my SQL developer software it executes just fine. Now to …