-
Notifications
You must be signed in to change notification settings - Fork 0
/
EfCarDal.cs
42 lines (41 loc) · 1.65 KB
/
EfCarDal.cs
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
33
34
35
36
37
38
39
40
41
42
using Core.DataAccess.EntityFramework;
using DataAccess.Abstract;
using Entities.Concrete;
using Entities.DTOs;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace DataAccess.Concrete.EntityFramework
{
public class EfCarDal : EfEntityRepositoryBase<Car, CarDbContext>, ICarDal
{
public List<CarDetailDto2> GetCarDetailDtos2(Expression<Func<Car, bool>> filter = null)
{
using (CarDbContext context = new CarDbContext())
{
var result = from c in filter == null ? context.Car : context.Car.Where(filter)
join b in context.Brand
on c.BrandId equals b.BrandId
join color in context.Color
on c.ColorId equals color.ColorId
join img in context.CarImages
on c.Id equals img.CarId
select new CarDetailDto2
{
CarId = c.Id,
ModelYear = c.ModelYear,
BrandName = b.BrandName,
ColorName = color.ColorName,
DailyPrice = c.DailyPrice,
Description = c.DescriptionCar,
ImagePath = img.ImagePath,
FindexPoint = c.FindexPoint
};
return result.ToList();
}
}
}
}