Skip to content

Instantly share code, notes, and snippets.

View ouzdev's full-sized avatar
:octocat:
I'm burdened with writing code

Oğuz Can Genç ouzdev

:octocat:
I'm burdened with writing code
View GitHub Profile
public class ProductDto
{
public string Name { get; set; }
public double UnitPrice { get; set; }
}
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
[Route("api/[controller]")]
public class ProductsController:Controller
{
private readonly ProductDbContext _context;
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<ProductDbContext>(options => options.UseInMemoryDatabase("Products"));
public class ProductDbContext:DbContext{
public ProductDbContext(DbContextOptions context):base(context)
{
}
public DbSet<Product> Products{get;set;}
}
public class Product{
public int Id { get; set; }
public string Name { get; set; }
public double UnitPrice { get; set; }
}
// Product tipinde listemizi oluşturup ürünleri ekledik.
List<string> products = new List<string>
{
"Sony Playstation 5 Oyun Konsolu",
"Xbox Series S Oyun Konsolu",
"Monster Abra A5 V9.2.2 Laptop",
"Xiomia Mi Band 5 Akıllı Biileklik",
"Sandisk Ultra 3D 500 GB Nvme SSD"
};
// Product tipinde listemizi oluşturup ürünleri ekledik.
List<string> products = new List<string>
{
"Sony Playstation 5 Oyun Konsolu",
"Xbox Series S Oyun Konsolu",
"Monster Abra A5 V9.2.2 Laptop",
"Xiomia Mi Band 5 Akıllı Biileklik",
"Sandisk Ultra 3D 500 GB Nvme SSD"
};
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
//LINQ sorgu sözdizimi
var query = from number in numbers
where number < 3
select number;
//LINQ metod sözdizimi
var method = numbers.Where(n => n < 3);
@ouzdev
ouzdev / factorial_ permutation_combination_calculator.cs
Last active December 21, 2019 10:31
Faktöriyel, Permütasyon, Kombinasyon Hesaplama
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@ouzdev
ouzdev / dort_islem_metod.cs
Created December 21, 2019 09:30
4 işlemin metod türleri ile yapılması
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;