How to add a '.Contains()' to the where clause of a query? - c#

I have this query but I need to add a where clause that uses 'Contains()' so I can check the db for a list of accountIDs, the reason I need to do it this way is because I have to first check if there are any accountID's and if there are it must execute the 'Contains()' in the where clause but the compiler complains if I try do it this way but given what the method has to do I can't figure out another way to do it given the fact that there are so many tables joined in the query.
My code:
bool UseAcc = false;
if (accountIds != null && accountIds.Count > 0)
{
UseAcc = true;
}
var query = (from i in db.Incidents
join s in db.Sites on i.SiteID equals s.SiteID
join a in db.Accounts on i.AccountID equals a.AccountID
join st in db.Status on i.StatusID equals st.StatusID
join currentUser in db.Users on i.CurrentAssignedUser equals currentUser.UserID
join loggedByUser in db.Users on i.LoggedByUser equals loggedByUser.UserID
join createdByUser in db.Users on i.CreatedByUser equals createdByUser.UserID
join l in db.Locations on i.Location equals l.LocationID into locList
from loc in locList.DefaultIfEmpty()
join q in db.QuestionCategories on i.QuestionCategoryID equals q.QuestionCategoryID
join ia in db.IncidentActions on i.IncidentID equals ia.IncidentID into iaList
from actions in iaList.DefaultIfEmpty()
//If 'UseAcc' gets set to true then execute the contains section of the or statement
where (i.Active == true) &&
(UseAcc = false || a => accountIds.Contains(a.AccountID))
select new
{
Title = i.Title,
IncidentID = i.IncidentID,
StatusName = st.StatusName,
StatusID = i.StatusID,
ReferenceNumber = i.ReferenceNo,
AccountName = a.AccountName,
AccountID = i.AccountID,
SiteName = s.SiteName,
SiteID = i.SiteID,
LocationName = loc.LocationName,
LocationID = i.Location,
CatName = q.QuestionCategoryName,
CatID = i.QuestionCategoryID,
CurrentAssignedUser = currentUser.FirstName + " " + currentUser.LastName,
AssignedUserID = i.CurrentAssignedUser,
CreatedByUser = createdByUser.FirstName + " " + createdByUser.LastName,
DateCreated = i.LoggedDate,
DepartmentID = i.DepartmentID,
Logger = loggedByUser.FirstName + " " + loggedByUser.LastName,
LoggedBy = i.LoggedByUser,
EscalationCount = i.EscalationCount)
});
I would paste the whole method but its really big.
I have looked at examples online but they can't work either because alot of them use an AsQueryable with a single table and this query has many tables joined.
Please Help.

var accounts = db.Accounts.AsQueryable();
if (accountIds != null && accountIds.Count > 0)
{
accounts = accounts.Where(a => accountIds.Contains(a.AccountID));
}
var query = (from i in db.Incidents
join s in db.Sites on i.SiteID equals s.SiteID
join a in accounts on i.AccountID equals a.AccountID
join st in db.Status on i.StatusID equals st.StatusID
join currentUser in db.Users on i.CurrentAssignedUser equals currentUser.UserID
join loggedByUser in db.Users on i.LoggedByUser equals loggedByUser.UserID
join createdByUser in db.Users on i.CreatedByUser equals createdByUser.UserID
join l in db.Locations on i.Location equals l.LocationID into locList
from loc in locList.DefaultIfEmpty()
join q in db.QuestionCategories on i.QuestionCategoryID equals q.QuestionCategoryID
join ia in db.IncidentActions on i.IncidentID equals ia.IncidentID into iaList
from actions in iaList.DefaultIfEmpty()
select new
{
Title = i.Title,
IncidentID = i.IncidentID,
StatusName = st.StatusName,
StatusID = i.StatusID,
ReferenceNumber = i.ReferenceNo,
AccountName = a.AccountName,
AccountID = i.AccountID,
SiteName = s.SiteName,
SiteID = i.SiteID,
LocationName = loc.LocationName,
LocationID = i.Location,
CatName = q.QuestionCategoryName,
CatID = i.QuestionCategoryID,
CurrentAssignedUser = currentUser.FirstName + " " + currentUser.LastName,
AssignedUserID = i.CurrentAssignedUser,
CreatedByUser = createdByUser.FirstName + " " + createdByUser.LastName,
DateCreated = i.LoggedDate,
DepartmentID = i.DepartmentID,
Logger = loggedByUser.FirstName + " " + loggedByUser.LastName,
LoggedBy = i.LoggedByUser,
EscalationCount = i.EscalationCount)
});

Related

The specified LINQ expression contains references to queries that are associated with different contexts c#

I have this simple function that returns a query, but when I try to join 2 tables in different databases, the error raised: The specified LINQ expression contains references to queries that are associated with different contexts.
here is my code.
private object projectcycleFilter(int? pid, int? cid, int UserId)
{
string[] res = { null, "" };
int?[] resint = { null, 0 };
var access_user = (from p in geotagging.webpages_UsersInRoles join s in geotagging.UserProfiles on p.UserId equals s.UserId where p.UserId == UserId select p).ToList();
var x = new object();
var geotaggingquery = (from xx in geotagging.sub_project select xx).AsEnumerable();
var nfmsquery = (from p in nfmsdb.request_for_refund join lr in nfmsdb.lib_regions on p.region_code equals lr.region_code join lp in nfmsdb.lib_provinces on p.prov_code equals lp.prov_code join lc in nfmsdb.lib_cities on p.city_code equals lc.city_code join lb in nfmsdb.lib_brgy on p.brgy_code equals lb.brgy_code join gts in geotaggingquery on p.sub_project_id equals gts.sub_project_id select new { lb, lc, lp, lr, p, gts }).AsEnumerable();
if (access_user.Select(x => x.RoleId).FirstOrDefault() > 2)
{
nfmsquery = (from p in nfmsdb.request_for_refund join lr in nfmsdb.lib_regions on p.region_code equals lr.region_code join lp in nfmsdb.lib_provinces on p.prov_code equals lp.prov_code join lc in nfmsdb.lib_cities on p.city_code equals lc.city_code join lb in nfmsdb.lib_brgy on p.brgy_code equals lb.brgy_code join gt in nfmsdb.user_municipal_access on p.city_code equals gt.city_code join gts in geotaggingquery on p.sub_project_id equals gts.sub_project_id where gt.user_id == UserId && gt.selected == true select new { lb, lc, lp, lr, p, gts }).AsEnumerable();
}
if (!resint.Contains(pid))
{
nfmsquery = nfmsquery.Where(x => x.gts.project_type_id == pid);
}
if (!resint.Contains(cid))
{
nfmsquery = nfmsquery.Where(x => x.gts.cycle_id == cid);
}
var result = nfmsquery.Select(x => new
{
sub_project_id = x.p.sub_project_id,
sub_project_name = x.p.sub_project_name,
region_name = x.lr.region_name,
region_code = x.lr.region_code,
prov_name = x.lp.prov_name,
prov_code = x.lp.prov_code,
city_name = x.lc.city_name,
city_code = x.lc.city_code,
brgy_code = x.lb.brgy_code,
brgy_name = x.lb.brgy_name,
request_for_refund_id = x.p.request_for_refund_id,
total_sub_project_cost = x.p.total_sub_project_cost,
total_program_cost = x.p.total_program_cost,
region_director = x.p.region_director,
lbp_branch = x.p.lbp_branch,
address = x.p.address,
lcc_amount = x.p.lcc_amount,
account_name = x.p.account_name,
bank_no = x.p.bank_no,
amount_requested = x.p.amount_requested,
tranche_id = x.p.tranche_id,
prev_amount_release = x.p.prev_amount_release,
cumul_total_request = x.p.cumul_total_request,
date_created = x.p.date_created,
date_requested = x.p.date_requested,
brgy_chair_name = x.p.brgy_chair_name,
bspmc_name = x.p.bspmc_name,
ac_name = x.p.ac_name,
lprao_name = x.p.lprao_name,
lprao_date = x.p.lprao_date,
rpc_name = x.p.rpc_name,
rpm_name = x.p.rpm_name,
ac_date = x.p.ac_date,
rpc_date = x.p.rpc_date,
rpm_date = x.p.rpm_date,
updated_by = x.p.updated_by,
date_updated = x.p.date_updated,
isdeleted = x.p.isdeleted,
}).ToList();
return result;
}
I also try var geotaggingquery = (from xx in geotagging.sub_project select xx).ToList() and `var nfmsquery = (from p in nfmsdb.request_for_refund join lr in nfmsdb.lib_regions on p.region_code equals lr.region_code join lp in nfmsdb.lib_provinces on p.prov_code equals lp.prov_code join lc in nfmsdb.lib_cities on p.city_code equals lc.city_code join lb in nfmsdb.lib_brgy on p.brgy_code equals lb.brgy_code join gts in geotaggingquery on p.sub_project_id equals gts.sub_project_id select new { lb, lc, lp, lr, p, gts }).ToList();, nothing happens.
Thanks in advance

Join two linq queries on one key column to get one result set

Here I want to join the out put of the first query(one column) to the result of the 2nd query to get a one result set. How can I merge them.(CONCAT doesn't work as required. eg: var query2 = query.concat(query1);)
var query = (from PP in _db.paymentPlans
join APP in _db.Applications on PP.applicationID equals APP.ApplicationId
join C in _db.Courses on APP.courseID equals C.courseID
where PP.active == true && APP.agentID == agentID
orderby C.courseID ascending
group new {C,PP} by new {C.courseID} into totalRecievable
select new PdPpAppCourseModel
{
courseID = totalRecievable.Key.courseID,
totalAmount = totalRecievable.Sum(x => x.PP.totalAmount)
}).ToList();
var query1=(from PD in _db.paymentDetails
join PP in _db.paymentPlans on PD.paymentPlanID equals PP.paymentPlanID
join APP in _db.Applications on PP.applicationID equals APP.ApplicationId
join C in _db.Courses on APP.courseID equals C.courseID
where PP.active == true && APP.agentID == agentID
orderby C.courseID ascending
group new { C,PD } by new { C.courseID, C.cricosCode, C.courseName } into paymentsCourseWise
select new PdPpAppCourseModel
{
courseID = paymentsCourseWise.Key.courseID,
cricosCode = paymentsCourseWise.Key.cricosCode,
courseName = paymentsCourseWise.Key.courseName,
paidAmount = paymentsCourseWise.Sum(x => x.PD.paidAmount)
}).ToList();
You could join query1 and query like this
var result = (from q1 in query1
join q in query on q1.courseID = q.courseID
select new PdPpAppCourseModel
{
courseID = q1.Key.courseID,
cricosCode = q1.Key.cricosCode,
courseName = q1.Key.courseName,
paidAmount = q1.Sum(x => x.PD.paidAmount),
totalAmount = q.totalAmount
}).ToList();

flatten out webapi EF using DTO and linq- using IF/THEN

I am attempting to flatten out my webapi EF using DTO's. So far I have the below statement working correctly. Now I want to add a layer of complexity stating a IF/THEN. I put a fake code in the first line of SELECT NEW SECTION.
Can someone please assist?
var query = (
from acctTbl in db.Accounts
join tradeTbl in db.Trades on acctTbl.AccountID equals tradeTbl.AccountID into ts
from tradeTbl in ts.DefaultIfEmpty()
join mapClientAcct in db.Mapping_ClientAccounts on acctTbl.AccountID equals mapClientAcct.AccountID
join clientTbl in db.Clients on mapClientAcct.ClientID equals clientTbl.ClientID
join mapUserClient in db.Mapping_UserClients on clientTbl.ClientID equals mapUserClient.ClientID
join aspNetUser in db.AspNetUsers on mapUserClient.AspNetUsersID equals aspNetUser.Id
join mktData in db.MarketDatas on tradeTbl.MarketDataID equals mktData.MarketDataID into ms
from mktData in ms.DefaultIfEmpty()
join mktCode in db.GMI_MarketCodes on tradeTbl.GMI_MarketCodesID equals mktCode.GMI_MarketCodesID into mc
from mktCode in mc.DefaultIfEmpty()
join Mgrs in db.Managers on acctTbl.ManagerID equals Mgrs.ManagerID
join FxMkts in db.ForexMarkets on mktData.crncy equals FxMkts.CurrencySymbol into fm
from FxMkts in fm.DefaultIfEmpty()
where acctTbl.AccountActive == true
&& clientTbl.ClientID == clientID
&& aspNetUser.UserName == username
select new TradeDetailDTO()
{
--THIS IS WHAT I WANT TO DO!!!
IF tradeTblIdentifier == "F" THEN 'yes'
ELSE 'no'
-------------------------
Filedate = tradeTbl.Filedate,
Quantity = tradeTbl.Quantity,
Month = tradeTbl.Month,
Strike = tradeTbl.Strike,
PutCall = tradeTbl.PutCall,
Prompt = tradeTbl.Prompt,
StmtPrice = tradeTbl.Price,
ShortDesc = mktCode.ShortDesc,
Sector = mktCode.Sector,
ExchName = mktCode.ExchName,
BBSymbol = mktData.BBSymbol,
BBName = mktData.Name,
fut_Val_Pt = mktData.fut_Val_Pt,
crncy = mktData.crncy,
fut_tick_size = mktData.fut_tick_size,
fut_tick_val = mktData.fut_tick_val,
fut_init_spec_ml = mktData.fut_init_spec_ml,
last_price = mktData.last_price,
bid = mktData.bid,
ask = mktData.ask,
px_settle_last_dt_rt = mktData.px_settle_last_dt_rt,
px_settle_actual_rt = mktData.px_settle_actual_rt,
chg_on_day = mktData.chg_on_day,
prev_close_value_realtime = mktData.prev_close_value_realtime,
AccountNumber = acctTbl.AccountNumber,
TradeLevel = acctTbl.TradeLevel,
ManagerName = Mgrs.ManagerName,
ManagerShortCode = Mgrs.ManagerShortCode,
ForexLastPrice = db.MarketDatas.FirstOrDefault(x => x.BBSymbol == mktData.crncy + " BGN CURNCY") == null ? 1: db.MarketDatas.FirstOrDefault(x => x.BBSymbol == mktData.crncy + " BGN CURNCY").last_price,
//ForexLastPrice = FxMkts.LastPrice, ORIGINAL
TopdayIdentifier = "P",
DailyPercentage = acctTbl.DailyPercentage,
AccountType = acctTbl.AccountType
}
);
If i understood you correctly you want something like this:
var query = (
from acctTbl in db.Accounts
join tradeTbl in db.Trades on acctTbl.AccountID equals tradeTbl.AccountID into ts
from tradeTbl in ts.DefaultIfEmpty()
join mapClientAcct in db.Mapping_ClientAccounts on acctTbl.AccountID equals mapClientAcct.AccountID
join clientTbl in db.Clients on mapClientAcct.ClientID equals clientTbl.ClientID
join mapUserClient in db.Mapping_UserClients on clientTbl.ClientID equals mapUserClient.ClientID
join aspNetUser in db.AspNetUsers on mapUserClient.AspNetUsersID equals aspNetUser.Id
join mktData in db.MarketDatas on tradeTbl.MarketDataID equals mktData.MarketDataID into ms
from mktData in ms.DefaultIfEmpty()
join mktCode in db.GMI_MarketCodes on tradeTbl.GMI_MarketCodesID equals mktCode.GMI_MarketCodesID into mc
from mktCode in mc.DefaultIfEmpty()
join Mgrs in db.Managers on acctTbl.ManagerID equals Mgrs.ManagerID
join FxMkts in db.ForexMarkets on mktData.crncy equals FxMkts.CurrencySymbol into fm
from FxMkts in fm.DefaultIfEmpty()
where acctTbl.AccountActive == true
&& clientTbl.ClientID == clientID
&& aspNetUser.UserName == username
select new TradeDetailDTO()
{
YesNo = tradeTbl.Identifier == "F"?"yes":"no",
Filedate = tradeTbl.Filedate,
Quantity = tradeTbl.Quantity,
Month = tradeTbl.Month,
Strike = tradeTbl.Strike,
PutCall = tradeTbl.PutCall,
Prompt = tradeTbl.Prompt,
StmtPrice = tradeTbl.Price,
ShortDesc = mktCode.ShortDesc,
Sector = mktCode.Sector,
ExchName = mktCode.ExchName,
BBSymbol = mktData.BBSymbol,
BBName = mktData.Name,
fut_Val_Pt = mktData.fut_Val_Pt,
crncy = mktData.crncy,
fut_tick_size = mktData.fut_tick_size,
fut_tick_val = mktData.fut_tick_val,
fut_init_spec_ml = mktData.fut_init_spec_ml,
last_price = mktData.last_price,
bid = mktData.bid,
ask = mktData.ask,
px_settle_last_dt_rt = mktData.px_settle_last_dt_rt,
px_settle_actual_rt = mktData.px_settle_actual_rt,
chg_on_day = mktData.chg_on_day,
prev_close_value_realtime = mktData.prev_close_value_realtime,
AccountNumber = acctTbl.AccountNumber,
TradeLevel = acctTbl.TradeLevel,
ManagerName = Mgrs.ManagerName,
ManagerShortCode = Mgrs.ManagerShortCode,
ForexLastPrice = db.MarketDatas.FirstOrDefault(x => x.BBSymbol == mktData.crncy + " BGN CURNCY") == null ? 1: db.MarketDatas.FirstOrDefault(x => x.BBSymbol == mktData.crncy + " BGN CURNCY").last_price,
//ForexLastPrice = FxMkts.LastPrice, ORIGINAL
TopdayIdentifier = "P",
DailyPercentage = acctTbl.DailyPercentage,
AccountType = acctTbl.AccountType
}
);

Linq To Sql Skip Take

I want to save each icon path into a variable, from the query bellow , only PathIcon1 has value . The remain path icon are empty
Query
using (CarteringServiceClientDataContext dc = new CarteringServiceClientDataContext())
{
result = (from a in dc.GetTable<tblSupplier>()
join b in dc.GetTable<tblCity>()
on a.CityId equals b.Id
join c in dc.GetTable<tblZone>()
on b.ZoneId equals c.Id
let r = (from re in dc.GetTable<tblClientReview>()
where re.SupplierId == a.Id
select re.note).Average()
let i = (from im in dc.GetTable<tblSupplierItem>()
where im.SupplierId == a.Id
select im.tblItem.IconPath).ToArray()
select new SearchResult
{
CompanyId = a.Id,
CompanyName = a.Company,
Localisation = a.Locality,
City = b.Name,
Zone = c.Name,
Rating = r.ToString(),
PathIcon1 = i.Take(1).SingleOrDefault(),
PathIcon2 = i.Skip(1).Take(1).SingleOrDefault(),
PathIcon3 = i.Skip(2).Take(1).SingleOrDefault(),
PathIcon4 = i.Skip(3).Take(1).SingleOrDefault(),
PathIcon5 = i.Skip(4).Take(1).SingleOrDefault()
}).ToList<SearchResult>();
}
A part from PathIcon1, the remaing PathIcon are null
using (CarteringServiceClientDataContext dc = new CarteringServiceClientDataContext())
{
result = (from a in dc.GetTable<tblSupplier>()
join b in dc.GetTable<tblCity>()
on a.CityId equals b.Id
join c in dc.GetTable<tblZone>()
on b.ZoneId equals c.Id
let r = (from re in dc.GetTable<tblClientReview>()
where re.SupplierId == a.Id
select re.note).Average()
let i = (from im in dc.GetTable<tblSupplierItem>()
where im.SupplierId == a.Id
select im.tblItem.IconPath).ToArray().Add("test")
select new SearchResult
{
CompanyId = a.Id,
CompanyName = a.Company,
Localisation = a.Locality,
City = b.Name,
Zone = c.Name,
Rating = r.ToString(),
PathIcon1 = i.Take(1).SingleOrDefault(),
PathIcon2 = i.Skip(1).Take(1).SingleOrDefault(),
PathIcon3 = i.Skip(2).Take(1).SingleOrDefault(),
PathIcon4 = i.Skip(3).Take(1).SingleOrDefault(),
PathIcon5 = i.Skip(4).Take(1).SingleOrDefault()
}).ToList<SearchResult>();
}
Try this if you are get PathIcon2 value as "test" your problem isn't skip or take. Just i list includes one item. Adn I think so.

How to get data which has Max Date in linq

Here is a linq query, and the table "Timesheet_Log" has DT_CR Column with type DateTime and I want to get the query with latest DT_CR Date, how is it possible?
var getEmployeeNames = (from emps in reslandentity.EMPLOYEE
join timesheet in reslandentity.TIMESHEET on emps.ID equals timesheet.RES_ID
join weekcal in reslandentity.WEEK_CALENDER on timesheet.WEEK_CAL_ID equals weekcal.ID
join log in reslandentity.TIMESHEET_LOG on timesheet.ID equals log.TIMESHEET_ID
join workflow in reslandentity.TIMESHEET_WORKFLOW on log.WORKFLOW_ID equals workflow.ID
where weekcal.WEEK_START_DT.Month == month
orderby log.DT_CR select new TimesheetModel
{
EMP_ID = emps.ID,
EMPLOYEE_NAME = emps.FIRST_NAME + " " + emps.LAST_NAME,
RES_TYPE = workflow.ORG_RES_TYPE,
EMP_STATUS = workflow.ACTION,
SDate = weekcal.WEEK_START_DT,
EDate = weekcal.WEEK_END_DT,
DT_CR=log.DT_CR
}).Distinct().ToList();
model.GetTimeSheetDetails = getEmployeeNames;
Please Help me to get the Query.
You've not made it clear if you expect just a single result or a list of results (1 per timesheet).
If you just need a single result the answer by lti Tyangi will be fine.
If you need a result per timesheet you could try the following:
var getEmployeeNames = (from emps in reslandentity.EMPLOYEE
join timesheet in reslandentity.TIMESHEET on emps.ID equals timesheet.RES_ID
join weekcal in reslandentity.WEEK_CALENDER on timesheet.WEEK_CAL_ID equals weekcal.ID
join mxLog in (
from lg in reslandentity.TIMESHEET_LOG
group lg by lg.TIMESHEET_ID into lgGrp
select new {lgGrp.Key, DT_CR = lgGrp.Max(x => x.DT_CR)}
) on timesheet.ID equals mxLog.Key
join log in reslandentity.TIMESHEET_LOG on new { a = mxLog.Key, b = mxLog.DT_CR} equals new{ a = log.TIMESHEET_ID, b = log.DT_CR}
join workflow in reslandentity.TIMESHEET_WORKFLOW on log.WORKFLOW_ID equals workflow.ID
where weekcal.WEEK_START_DT.Month == month
orderby log.DT_CR select new TimesheetModel
{
EMP_ID = emps.ID,
EMPLOYEE_NAME = emps.FIRST_NAME + " " + emps.LAST_NAME,
RES_TYPE = workflow.ORG_RES_TYPE,
EMP_STATUS = workflow.ACTION,
SDate = weekcal.WEEK_START_DT,
EDate = weekcal.WEEK_END_DT,
DT_CR=log.DT_CR
}).Distinct().ToList();
model.GetTimeSheetDetails = getEmployeeNames;
here we join onto a grouping of the logs per timesheet to get the maximum date per timesheet, and then join to the logs based on both the id of the timesheet and that date
var getEmployeeNames = (from emps in reslandentity.EMPLOYEE
join timesheet in reslandentity.TIMESHEET on emps.ID equals timesheet.RES_ID
join weekcal in reslandentity.WEEK_CALENDER on timesheet.WEEK_CAL_ID equals weekcal.ID
join log in reslandentity.TIMESHEET_LOG on timesheet.ID equals log.TIMESHEET_ID
join workflow in reslandentity.TIMESHEET_WORKFLOW on log.WORKFLOW_ID equals workflow.ID
where weekcal.WEEK_START_DT.Month == month
//orderby log.DT_CR
select new TimesheetModel
{
EMP_ID = emps.ID,
EMPLOYEE_NAME = emps.FIRST_NAME + " " + emps.LAST_NAME,
RES_TYPE = workflow.ORG_RES_TYPE,
EMP_STATUS = workflow.ACTION,
SDate = weekcal.WEEK_START_DT,
EDate = weekcal.WEEK_END_DT,
DT_CR=log.DT_CR
}).OrderByDescending(x=>x.DT_CR).FirstorDefault();
OR
var getEmployeeNames = (from emps in reslandentity.EMPLOYEE
join timesheet in reslandentity.TIMESHEET on emps.ID equals timesheet.RES_ID
join weekcal in reslandentity.WEEK_CALENDER on timesheet.WEEK_CAL_ID equals weekcal.ID
join log in reslandentity.TIMESHEET_LOG on timesheet.ID equals log.TIMESHEET_ID
join workflow in reslandentity.TIMESHEET_WORKFLOW on log.WORKFLOW_ID equals workflow.ID
where weekcal.WEEK_START_DT.Month == month
//orderby log.DT_CR
select new TimesheetModel
{
EMP_ID = emps.ID,
EMPLOYEE_NAME = emps.FIRST_NAME + " " + emps.LAST_NAME,
RES_TYPE = workflow.ORG_RES_TYPE,
EMP_STATUS = workflow.ACTION,
SDate = weekcal.WEEK_START_DT,
EDate = weekcal.WEEK_END_DT,
DT_CR=log.DT_CR
}).OrderByDescending(x=>x.DT_CR).ToList().Take(1);

Categories