Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

dotnet core ef add multiple records

 
using (EFCoreContext db = new EFCoreContext())
{
    List<Department> deps = new List<Department>();
 
    deps.Add(new Department { Name = "Dept1", Descr = "" });
    deps.Add(new Department { Name = "Dept2", Descr = "" });
 
    db.Departments.AddRange(deps);
    db.SaveChanges();
}
 
//SQL Command
INSERT INTO [Departments] ([Descr], [Name])
VALUES (@p0, @p1);
 
SELECT [DepartmentID]
FROM [Departments]
WHERE @@ROWCOUNT = 1 AND [DepartmentID] = scope_identity();
          
INSERT INTO [Departments] ([Descr], [Name])
VALUES (@p0, @p1);
         
SELECT [DepartmentID]
FROM [Departments]
WHERE @@ROWCOUNT = 1 AND [DepartmentID] = scope_identity();
 
Comment

PREVIOUS NEXT
Code Example
Csharp :: internet connection sharing 
Csharp :: Hangfire Creation Table With EFCore 
Csharp :: join 2 list rows into one row and add totals fields C# 
Csharp :: localhost ssl certificate error in visual studio 2022 .net 6 
Csharp :: unity save slots 
Csharp :: c# call by reference 
Csharp :: dfgf 
Csharp :: serenity.is required field 
Csharp :: json string to JObject object c# camelCasing key .net 
Csharp :: Align String with Spaces [C#] 
Csharp :: DisplayUnitType revit 2022 
Csharp :: excute same code mvc 
Csharp :: CRUD configuration MVC with Firebase 
Csharp :: how to select class object from query c# 
Csharp :: Runtime.getRuntime().addShutdownHook(printingHook); c# 
Csharp :: c# check if object can be cast to type 
Csharp :: C# string go to line 
Csharp :: long to binary c# 
Csharp :: c# get digits from int 
Csharp :: C# verify "no other" call xunit 
Csharp :: c# functions 
Csharp :: prime number generator 
Csharp :: list dictionary c# 
Csharp :: unity overlapcircle 
Csharp :: get index of item unity 
Csharp :: c# arraylist to listview 
Csharp :: unity input tastiera 
Csharp :: 10x10 table matrix C# 
Html :: ion-item remove bottom line 
Html :: rs logo html 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =