i would like to convert my SQL Query to a LINQ one
SELECT [SCN_CIM_CONTROLNUM] as 'Control Number',SUBSTRING(SCN_SUBS_CODE,1,16) as 'Substrate Code', SUM(SCN_COUNT) as 'Total Count' FROM [Inventory].[dbo].[SCAN_TRANS_LOG] WHERE SCN_UID = 'admin02' GROUP BY SUBSTRING(SCN_SUBS_CODE,1,16), [SCN_CIM_CONTROLNUM]
i Have read an select * from Inventory to my Datatable
Break it down into phases. First filter to narrow down rows. Then select to narrow down columns. Then group.
@Hexxed That's kinda missing the point. Using a LINQ DB framework, like Linq to SQL or Entity Framework, will allow you to write LINQ code in your C# and have it converted automatically to SQL Statements.
Doing it with DataTables means retrieving your data manually, then doing LINQ queries in-memory.
But the process is the same.
var adminLogs = SCAN_TRANS_LOGS.Where(log => log.SCN_UID = "admin02");
var relevantRows = adminLogs.Select(log => new { ControlNumber = log.SCN_CIM_CONTROLNUM, SubstrateCode=log.SCN_SUBS_CODE.Substring(0,16)});
var groupedRows = relevantRows.GroupBy(log => log.SubstrateCode);
For some reason I couldn't post a message. I doubt it was too long. Submit button just did nothing (mobile)
@Hexxed this might be kind of early to bring this up, Avner hinted at it, but here goes...
@Hexxed The query you're doing might turn out to be inefficient, because you're querying an in-memory collection which means the whole dataset has already been pulled from the database (assuming you're using a database). Another way to do this is to use a data context. What this does is actually translates your LINQ into SQL statements and runs that against the underlying database, so you only ever touch the rows you're interested in, rather than loading the whole table
Ok, so it was too long
@Basil could be inheriting permissions from its parent folder
@Basil although I still don't understand the question; if the file is readonly, why would you expect to be allowed to open it for writing?
does it make sense to add a message handler in webapi to route all non existing controllers to one place? currently I have empty controllers that route themselves to their base class
@SteffenWinkler The most important thing to know about ++x is to be careful whenever you see it in someone else's code. Chances are the guy's being too clever.
In fact, I try to avoid the ++ operator completely and use += 1 instead. Much clearer.
my first job out of university. It was a really shonky operation. I was doing some server maintenance and I accidentally stepped on a cable which pulled the power cord out of the wall. The UPS lasted 2 seconds.
@Squiggle huh, that's just like when I'm at a someone else's house/apartment to set up their internet connection and they do not have their login around...
@Squiggle heared off it but never seen that in person, must be eerie.
Way back when I was in IT, we had a catastrophic power failure take out the entire server room's power. It was a big org - we were the PC IT team, and there were Unix teams, Mainframe teams, DBA teams, etc. Suddenly everyone burst out of their offices at the same time and rushed down to the basement.
About 30 people, none of them particularly used to running, heading down three floors at breakneck speeds.
@Squiggle had a new server was setting up next to my desk, and a client came in with his kid and the kid stepped on the powercable taking the new server out while it was in the middle of a restore :<
@Asheh uhh. I'm more involved in Vim regex. In vim regex You need \ before + also. Do You need ^ at the beginning? Whole input should be matched, or just the end?
But from the link @ntohl posted,
dateString = "18/08/2015 06:30:15.006542";
format = "dd/MM/yyyy hh:mm:ss.ffffff";
try {
result = DateTime.ParseExact(dateString, format, provider);
Console.WriteLine("{0} converts to {1}.", dateString, result.ToString());
@Sippy Well I've made a class Clock. It just runs as a normal clock. A user types for example 12:30 in an textbox. This is now the alarm. If clock = 12:30, the alarm will go off for x seconds (also chosen my user, default 10)
The part where I'm stuck at is how I can let the user type "HOUR:MINUTE" and make my code interpet it as such. Making 2 textboxes would be an easy solution but you know, lazy.
string input = "21:32";
TimeSpan parsed;
if (TimeSpan.TryParseExact(input, "H:mm", CultureInfo.InvariantCulture.DateTimeFormat, out parsed))
{
// do good shit
}
DataTable dtSelected; var dr = from row in dt.AsEnumerable() where row.Field<string>("ItemID") == "strigVariableValue" select row;
this returns no rows but the datatatble contains value.... what will be the reason.. I have also tried datatable.Select method... not working ... filtering is working with Int values but not working with string alues
string input = "21:32";
DateTime parsed;
if (DateTime.TryParseExact(input, "H:mm", CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.None, out parsed))
{
// do good shit
int k = 3;
}
@ntohl: You should've used the "g" format specifier. dotnetfiddle.net/NYoWbs, and as @AvnerShahar-Kashtan said, the format specifiers are different than for DateTimes.
string input = "21:32";
TimeSpan parsed;
if (TimeSpan.TryParseExact(input, @"h\:mm", CultureInfo.InvariantCulture.DateTimeFormat, out parsed))
{
// do good shit
}
@Sippy lol nope I quit a couple of weeks later, then the company imploded because it didn't have any technical staff (and because the boss siphoned off the assets and fled to Kuala Lumpur in the middle of a court case)
@misha130 this was the same place that I discovered was a porn host on my first day of work, after finding a (legit) folder on my new desktop called C:/PORN
"The Spark of Life system also helps reduce griefing. If you kill another character in-game, your face goes up on a wanted poster and a bounty token is created for you. This not only keeps you out of cities, but also means you can be taken to 'jail' which significantly reduces your lifespan, adding real financial repercussions to your in-game decisions. "
@misha130 Yep, so much potential in wrong hands.. There are 2 teams working on making it the game it was supposed to be right now. And one of teams are doing pretty good
@Sippy Shieeet bro.. Shieeet. At least Mothers would consider me. When they see you, they are afraid of getting sued