Files
FA_WEB/SytelineSaAppEfDataModel/Services/WzRowMeyleService.cs

21 lines
698 B
C#

using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Entities;
namespace SytelineSaAppEfDataModel.Services;
public class WzRowMeyleService(SytelineSaAppDbContext context, IMapper mapper) : IWzRowMeyleService
{
public async Task<IEnumerable<WzRowMeyleDto>> GetAll()
{
return await context.WzRowsMeyle.Select(x => mapper.Map<WzRowMeyleDto>(x)).ToListAsync();
}
public async Task CreateRows(IEnumerable<WzRowMeyleDto> rows)
{
var entities = mapper.Map<IEnumerable<WzRowMeyle>>(rows);
await context.WzRowsMeyle.AddRangeAsync(entities);
await context.SaveChangesAsync();
}
}