public IEnumerable <WebApplication5.Models.File> Take(int index, int count) { using (AdventureWorks2019Context db = new AdventureWorks2019Context()) { // получаем объекты из бд и выводим на консоль var images = db.Files.Skip(index).Take(count); return(images.ToArray()); } }
public void GlobalSetup() { _conn = new SqlConnection(_connstring); _conn.Open(); var contextOptions = new DbContextOptionsBuilder <AdventureWorks2019Context>() .UseSqlServer(_connstring) .Options; _dbcontext = new AdventureWorks2019Context(contextOptions); }
public IEnumerable <Address> Get200() { var rng = new Random(); using (AdventureWorks2019Context db = new AdventureWorks2019Context()) { // получаем объекты из бд и выводим на консоль var adresses = db.Addresses.Take(200); return(adresses.ToArray()); } }
public async Task <IActionResult> UploadFile(IFormFileCollection _files) { foreach (IFormFile _file in _files) { if (_file != null) { Models.File file = new Models.File() { }; using (AdventureWorks2019Context db = new AdventureWorks2019Context()) { db.Files.Add(file); await db.SaveChangesAsync(); } string path = "/Files/" + file.Id + System.IO.Path.GetExtension(_file.FileName); using (var fileStream = new FileStream(_applicationEnvironment.WebRootPath + path, FileMode.Create)) { await _file.CopyToAsync(fileStream); using (AdventureWorks2019Context db = new AdventureWorks2019Context()) { file.Name = _file.FileName; file.Path = path; db.Files.Update(file); await _file.CopyToAsync(fileStream); await db.SaveChangesAsync(); } } } } return(Redirect("/fetch-data")); }
public ProductController(AdventureWorks2019Context context, ILogger <ProductController> logger) { _context = context; _logger = logger; }
public AdventureWorksRepository(AdventureWorks2019Context context) { _context = context; }
public CurrenciesController(AdventureWorks2019Context context) { _context = context; }
public EmployeeController(AdventureWorks2019Context context) { _context = context; }
public ProductController(AdventureWorks2019Context context) { _context = context; }
public PersonController(AdventureWorks2019Context context) { _context = context; }
public CustomerController(AdventureWorks2019Context context) { _context = context; }