
the data is also attached. How do I have it in C# LINQ?
I try below, it does not return value of 3, but total number of different times. I need to have the word trunc in LINQ. thanks.
int TotalDays = (from p in context.PPL_PRODUCT_TESTID2
where p.MONO == Mono && p.ITNO == PartNo && p.SYSTEMTYPE == "0036" && p.TESTFLAG == 1
select p.TIMESTAMP).Distinct().Count(); // all timestamp MO

Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 11:20 PM EDT
p.TESTFLAG == 1
Regards,
Iftikar
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 18, 2013, 8:46 PM EDT
In linq use Truncate(p.TIMESTAMP)
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 18, 2013, 9:19 PM EDT
above does not work.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 18, 2013, 9:27 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 18, 2013, 9:41 PM EDT
as seen below:
the problem is C# does not recognize the word Truncate. Do we need to add any reference?
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 18, 2013, 10:01 PM EDT
p.TIMESTAMP.ToString("MM/dd/yyyy")
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 18, 2013, 10:23 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 18, 2013, 10:32 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 18, 2013, 10:36 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 18, 2013, 10:52 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 18, 2013, 11:21 PM EDT
even with say
it displays all those 3 different dates...
What I want to do is to get the value of 3 in C# LINQ.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 18, 2013, 11:24 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 18, 2013, 11:44 PM EDT
your above gives this output which is useful for me.
I would need my C# program to get the value of 3 too.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 12:16 AM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 19, 2013, 12:27 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 12:44 AM EDT
p.TESTFLAG == 1
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 19, 2013, 12:48 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 1:06 AM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 19, 2013, 4:20 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 9:04 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 19, 2013, 10:35 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 19, 2013, 10:47 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 20, 2013, 3:20 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 20, 2013, 9:25 PM EDT
Can I check how can I extract out those 4 dates of type string from TotalDays?
Also, how can I extract out those 4 values (177, 120, 204, 1) of type int from TotalDays?
thanks.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 20, 2013, 9:38 PM EDT
IEnumerable
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 20, 2013, 9:57 PM EDT
it would have this error:
base {System.SystemException} = {"LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression."}
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 20, 2013, 9:58 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 20, 2013, 10:23 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 20, 2013, 10:26 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 20, 2013, 10:32 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 20, 2013, 10:35 PM EDT
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 21, 2013, 9:42 PM EDT
but in LINQPAD, it is sorted in the ascending order which I want?
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 21, 2013, 9:52 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 21, 2013, 10:11 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 21, 2013, 10:26 PM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 21, 2013, 10:40 PM EDT
where p.MONO == Mono && p.ITNO == PartNo && p.SYSTEMTYPE == "0036" && p.TESTFLAG == 1
orderby p.TIMESTAMP
select p.TIMESTAMP).Distinct(); // all timestamp MO
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 21, 2013, 10:42 PM EDT
if it does not work then share your screen
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 22, 2013, 12:25 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 22, 2013, 1:04 AM EDT
Regards,
Iftikar
TAN WhoAMIRank #5,790 · 286 reputationPosted Aug 29, 2013, 7:33 PM EDT