TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marius Vasile
601
1.9k
143.1k
asp.net core simplifying linq query use in razor project
Mar 20 2021 6:27 AM
I am using below query and other similar in 90% of my pages. is there a way to have it in one file and call it from there?
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var orgid = await _context.UsersData.Where(s => s.Id == userId).Select(s => s.OrgID).FirstOrDefaultAsync();
WOAssetViews = await(from a in _context.WOAssetLocations.Where(s => s.OrgID == orgid)
join b in _context.WOAssetAssets on a.WOALId equals b.WOALId into TempData1
from c in TempData1.DefaultIfEmpty()
join d in _context.WOAssetEquipments on c.WOAId equals d.WOAId into TempData2
from e in TempData2.DefaultIfEmpty()
join f in _context.WOAssetComponents on e.WOAEId equals f.WOAEId into TempData3
from g in TempData3.DefaultIfEmpty()
select
new
WOAssetView
{
WOALId = a.WOALId,
AssetLocation = a.AssetLocation,
AssetID = c.AssetID,
AssetName = c.AssetName,
AssetManufacturer = c.AssetManufacturer,
EquipmentID = e.EquipmentID,
EquipmentName = e.EquipmentName,
EquipmentManufacturer = e.EquipmentManufacturer,
ComponentID = g.ComponentID,
ComponentName = g.ComponentName,
ComponentManufacturer = g.ComponentManufacturer
}).ToListAsync();
Reply
Answers (
4
)
why using task async in asp c#
Gridview checkbox change colour