Моя таблица Таблица ClinicalAsset не будет отображать все результаты + любые результаты сопоставления из таблицы ClinicalPAT, где ClinicalAssetID является совпадением.
У меня есть один результат, который находится в таблице ClinicalPAT, которая соответствует таблице ClinicalAsset,но отображается только в MVC View, а не 40 результатов в таблице ClinicalAsset
Вот что я пробовал:
var clinicalAssets = (from PATasset in db.ClinicalPATs
join s in db.ClinicalAssets on PATasset.ClinicalAssetID equals s.ClinicalAssetID into output
from j in output.DefaultIfEmpty()
select new ClinicalASSPATVM
{
ClinicalAssetID = PATasset.ClinicalAssetID,
ProductName = j.ProductName,
InspectionDocumnets = PATasset.InspectionDocumnets,
});
var clinicalAssets = (from PATasset in db.ClinicalPATs
join s in db.ClinicalAssets on PATasset.ClinicalAssetID equals s.ClinicalAssetID into output
from j in output.DefaultIfEmpty(new ClinicalAsset())
select new ClinicalASSPATVM
{
ClinicalAssetID = PATasset.ClinicalAssetID,
ProductName = j.ProductName,
InspectionDocumnets = PATasset.InspectionDocumnets,
});
var clinicalAssets = (from PATasset in db.ClinicalPATs
join s in db.ClinicalAssets on PATasset.ClinicalAssetID equals s.ClinicalAssetID
select new ClinicalASSPATVM
{
ClinicalAssetID = PATasset.ClinicalAssetID,
ProductName = s.ProductName,
Inspect
var clinicalAssets = from PATasset in db.ClinicalPATs
join s in db.ClinicalAssets on PATasset.ClinicalAssetID equals s.ClinicalAssetID
select new ClinicalASSPATVM
{
ClinicalAssetID = PATasset.ClinicalAssetID,
ProductName = s.ProductName,
InspectionDocumnets = PATasset.InspectionDocumnets,
};
var clinicalAssets = from s in db.ClinicalAssets
join PATasset in db.ClinicalPATs on s.ClinicalAssetID equals PATasset.ClinicalAssetID
select new ClinicalASSPATVM
{
ClinicalAssetID = PATasset.ClinicalAssetID,
ProductName = s.ProductName,
InspectionDocumnets = PATasset.InspectionDocumnets,
};
var clinicalAssets = (from s in db.ClinicalAssets
join cp in db.ClinicalPATs on s.ClinicalAssetID equals cp.ClinicalAssetID
select new ClinicalASSPATVM
{
ClinicalAssetID = cp.ClinicalAssetID,
ProductName = s.ProductName,
InspectionDocumnets = cp.InspectionDocumnets,
});
Вот мой общий контроллер:
public ActionResult DashBoard(string sortOrder, string currentFilter,string searchString, int? page)
{
ViewBag.CurrentSort = sortOrder;
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";
if (searchString != null)
{
page = 1;
}
else
{
searchString = currentFilter;
}
ViewBag.CurrentFilter = searchString;
var clinicalAssets = (from s in db.ClinicalAssets
join cp in db.ClinicalPATs on s.ClinicalAssetID equals cp.ClinicalAssetID
select new ClinicalASSPATVM
{
ClinicalAssetID = cp.ClinicalAssetID,
ProductName = s.ProductName,
InspectionDocumnets = cp.InspectionDocumnets,
});
if (!String.IsNullOrEmpty(searchString))
{
clinicalAssets = clinicalAssets.Where(s => s.SerialNo.Contains(searchString)
|| s.PoNo.Contains(searchString));
}
switch (sortOrder)
{
case "name_desc":
clinicalAssets = clinicalAssets.OrderByDescending(s => s.PoNo);
break;
case "Date":
clinicalAssets = clinicalAssets.OrderBy(s => s.PurchaseDate);
break;
default:
clinicalAssets = clinicalAssets.OrderBy(s => s.ClinicalAssetID);
break;
}
int pageSize = 10;
int pageNumber = (page ?? 1);
return View(clinicalAssets.ToPagedList(pageNumber, pageSize));
}
````