This repository was archived by the owner on Sep 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (26 loc) · 1.65 KB
/
Program.cs
File metadata and controls
32 lines (26 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Microsoft.EntityFrameworkCore;
using ModelApp;
using ModelApp.DAL;
Initializer.Build();
using (AppDbContext context = new())
{
//List<ProductFull> productFulls = await context.ProductFulls.FromSqlRaw(@"SELECT p.Id 'Product_Id',c.Name 'CategoryName', p.Name,p.Price,pf.Height FROM Products p
// INNER JOIN ProductFeatures pf ON pf.Id = p.Id
// INNER JOIN Categories c ON c.Id = p.CategoryId").ToListAsync();
//Category category = new() { Name = "Kalemler" };
//category.Products.Add(new() { Name = "Kalem 1", Price = 100, Stock = 200, Barcode = 123, ProductFeature = new() { Color = "Red", Height = 200, Width = 100 } });
//category.Products.Add(new() { Name = "Kalem 2", Price = 100, Stock = 200, Barcode = 123, ProductFeature = new() { Color = "Red", Height = 200, Width = 100 } });
//category.Products.Add(new() { Name = "Kalem 3", Price = 100, Stock = 200, Barcode = 123, ProductFeature = new() { Color = "Red", Height = 200, Width = 100 } });
//context.Person2s.Add(new() { FirstName = "Ahmet", LastName = "Yılmaz" });//Primary Key olmadığı için hata aldık
//await context.SaveChangesAsync();
//List<Person2> person2s = await context.Person2s.ToListAsync();
//await context.Categories.AddAsync(category);
//await context.SaveChangesAsync();
Product product = new() { Name = "Kalem 1", Price = 100, DiscountPrice = 120, Barcode = 123, Stock = 1, Url = "abc" };
if (product.DiscountPrice <= product.Price)
{
await context.Products.AddAsync(product);
await context.SaveChangesAsync();
}
Console.WriteLine("İşlem Bitti");
}