Регистрация не работает в EntityFramewrok Core - PullRequest
0 голосов
/ 15 мая 2018

Я пытаюсь применить объединение в EF Core, но оно возвращает неверные данные.

Если я запускаю приведенный ниже запрос в SQL Server, он не возвращает результатов, его ожидаемое поведение.

select * from device d
inner join  store s on s.Id = d.StoreId
inner join category c on c.Id = d.CategoryId
where s.StoreName like '%dsfd%' and c.CategoryName like '%asdasdasd1%'

Но когда я пытаюсь запустить аналогичный код из приложения C # для тех же самых входных значений, он возвращает одну строку.

var serachresult = (from devices in _deviceRepository.GetAll()
join stores in _storeRepository.GetAll() on devices.StoreId equals stores.Id
join categories in _categoryRepository.GetAll() on devices.CategoryId equals categories.Id 
where

(!string.IsNullOrWhiteSpace(searchInput.StoreName) ? stores.StoreName.Contains(searchInput.StoreName) : true) &&

(!string.IsNullOrWhiteSpace(searchInput.CategoryName) ? categories.CategoryName.Contains(searchInput.CategoryName) : true) 

select new DeviceDetailsDto

{
    Id = devices.Id,
    DeviceName = devices.DeviceName,
    DeviceDesc = devices.DeviceDesc,
    DeviceCode = devices.DeviceCode,
    StoreId = devices.StoreId,
    CategoryId = devices.CategoryId,
    CategoryName = categories.CategoryName,
    StoreName = stores.StoreName
});

Возвращенная запись

Id, AssetID, CategoryId, CreationTime, CreatorUserId, DeleterUserId, DeletionTime, DeviceCode, DeviceDesc, DeviceName, FlgActive, IsDeleted, LastModificationTime, LastModifierUserId, StoreId, Id, AddressLine1, AddressLine2, Город, Страна, CreationTime, CreatorUserId, DeleterUserId, DeletionTime, EmailAddress, FlgActive, IsDeleted, LastModificationTime, LastModifierUserId, PhoneNo, Индекс, Штат, StoreDesc, StoreName, StoreNo, Id, CategoryDesc, CategoryName, CreationTime, CreatorUserId, DeleterUserId, DeletionTime, FlgActive, ImageName, ImagePath, IsDeleted, IsLast, LastModificationTime, LastModifierUserId, Level, ParentId, StoreId, TemplatesTypesId '3', '123123123', '21', '2018-05-14 18: 02: 58.480972', '2', NULL, NULL, 'asdasd', 'asdasd', 'asdasd', '1', '0', NULL, NULL, «1», «1», «asdasdasd», «asdasd», «dasasd», «sdasd», «2018-05-09 17: 14: 47.141586 ',' 1 ',' 0 ',' 2018-05-10 11: 48: 34.897152 ', 'dasdasd@gmail.com', '0', '0', NULL, NULL, 'asdsadsa', 'dasdasd', «asdas», «dsfdsf», «dsfd», «fdsdf», «21», «AASAS», «asS», «2018-05-10 11: 30: 05.237959 ',' 1 ', NULL, NULL,' 0 ',' img2.jpg ', 'C: \ workspace \ src \ Nec.Spar.Web.Host \ img2.jpg', '0', '1', NULL, NULL, '0', '0', '1', NULL

Обновление:

Возвращенная запись с меньшим количеством столбцов

Id, DeviceCode, DeviceDesc, DeviceName, StoreId, StoreName, CategoryId, CategoryName '3', 'asdasd', 'asdasd', 'asdasd', '1', 'dsfd', '21', 'asS'

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...