Regulate this
Sunday, October 25, 2020
Saturday, June 20, 2020
Linq Query Help
This is a problem that has had me stumped for a few days, and countless searches have not lead me to a solution. This seems like a fairly basic technique, but I have had no luck with it, since I am not exactly a master using linq queries. Hopefully, this is presented in a way to clearly show what I'm after. I've chiseled-down the classes and code that I'm actually using, into a more simplified example so I can focus on the part of the solution that is causing me problems.
I am working on an older database application that uses .Net Web Forms, and the first step to a long process of revamping this application has lead me to a problem with Entity Framework 6. Actually, it's a problem with me not knowing how to do something in Entity Framework, more specifically, with a Linq query. I don't want to go too far into detail, so I'm simplifying a few of the Entity Diagrams here, then I'll ask for help in cracking the nut that I have been unable to crack.
The relationship is a one-to-many relationship between the Issues and Comments. One Issue can have many comments. My ultimate question is, how can I use a Linq query to come up with columns like this? The Comments Column is a concatenation of the CommentText Fields in each of the Comment Entities related to the Issue for each row.
I can do this with SQL easy enough and concatenate the Comments into one column using a sub-query like so:
There are probably cleaner ways to get this done in SQL in more recent versions, but this is something I've been using since around 2007. I am considering using a Stored Procedure in my database, but I don't want to have these decisions made based on the fact that I don't know how to do something with one technology vs. the other.
Here is my attempt so far. I've created a C# class to act as a View Model
And here is part of the IssueFactory class and the function that will return the List of the IssueViewModel class. It seems like such a simple thing, and yet, here I am:
So that's it. Googling has gotten me nowhere with this for a few days. I thought I was going to be slick, and tried to call another function that I had created that built the bulleted list, but of course, linq queries can't call C# code like this, unfortunately.
So what's the piece of the puzzle that I have been missing? Anyone?
Thanks, in advance!
I am working on an older database application that uses .Net Web Forms, and the first step to a long process of revamping this application has lead me to a problem with Entity Framework 6. Actually, it's a problem with me not knowing how to do something in Entity Framework, more specifically, with a Linq query. I don't want to go too far into detail, so I'm simplifying a few of the Entity Diagrams here, then I'll ask for help in cracking the nut that I have been unable to crack.
Simplified Entities
Desired result |
I can do this with SQL easy enough and concatenate the Comments into one column using a sub-query like so:
SQL Query with a sub-query for Comments |
There are probably cleaner ways to get this done in SQL in more recent versions, but this is something I've been using since around 2007. I am considering using a Stored Procedure in my database, but I don't want to have these decisions made based on the fact that I don't know how to do something with one technology vs. the other.
Here is my attempt so far. I've created a C# class to act as a View Model
And here is part of the IssueFactory class and the function that will return the List
So that's it. Googling has gotten me nowhere with this for a few days. I thought I was going to be slick, and tried to call another function that I had created that built the bulleted list, but of course, linq queries can't call C# code like this, unfortunately.
So what's the piece of the puzzle that I have been missing? Anyone?
Thanks, in advance!
Wednesday, June 19, 2019
Environment Variables
To list the Environment Variables in Windows 10, open up a PowerShell Prompt.
This is a simple command to see the list of EVs on your system.
To set a variable:
The parameters are:
To list the Environment Variables in Windows 10, open up a PowerShell Prompt.
This is a simple command to see the list of EVs on your system.
To set a variable:
The parameters are:
- Name of the variable you want to set.
- The value of the variable you want to set.
- The level of access to the variable.
Thursday, June 23, 2016
Days 17 and 18
Yesterday got away from me as far as posting on the blog. Day 17 was just a 4 mile recovery run, so it was very uneventful anyway. Running 4 miles at a very easy pace...there really isn't much to say! It was an enjoyable run, and I even got up at 4:30 like I would for a much longer run. It was good to get the run over and have time to come back home and relax for a while before having to head in to work.
Today's run, TD18, was an 8 mile run with 4 miles at threshold pace. I was actually looking forward to this run since I had such a good day on Tuesday. This is the exact run that I did on TD2, but that one didn't work out as well as this one. I still had to work to keep the pace in my threshold range, but not nearly like I did 16 days ago. I must have run nearly the identical route, as I just looked back and saw that I finished last time at the base of the same hill that I finished the threshold legs today.
I ran the cooldown a bit under 10 minute pace...nearly a full minute faster than the Day 2 run. I was only cooling down at a comfortable pace in both runs, so I suppose that's a good sign for conditioning. Of course, it could just be a good week, but I'll go with the former for now!
I felt the work that I did on my quads all day at work. They were pretty sore from the weeks work, and I'm sure it will be nice to have a day of rest tomorrow. I'm already looking forward to Sunday and running 14 miles! It will only be the 8th time I've run at least that long. So ready to get to it!
Today's run, TD18, was an 8 mile run with 4 miles at threshold pace. I was actually looking forward to this run since I had such a good day on Tuesday. This is the exact run that I did on TD2, but that one didn't work out as well as this one. I still had to work to keep the pace in my threshold range, but not nearly like I did 16 days ago. I must have run nearly the identical route, as I just looked back and saw that I finished last time at the base of the same hill that I finished the threshold legs today.
I ran the cooldown a bit under 10 minute pace...nearly a full minute faster than the Day 2 run. I was only cooling down at a comfortable pace in both runs, so I suppose that's a good sign for conditioning. Of course, it could just be a good week, but I'll go with the former for now!
I felt the work that I did on my quads all day at work. They were pretty sore from the weeks work, and I'm sure it will be nice to have a day of rest tomorrow. I'm already looking forward to Sunday and running 14 miles! It will only be the 8th time I've run at least that long. So ready to get to it!
Tuesday, June 21, 2016
Training Day 16
Today was a good day! The run was a General Aerobic 10 mile run with a planned pace of between 9:30 and 10:30. I ran a route to a place that I had been many times, with not a lot of uphill, but enough to keep me honest. I had the workout broken into 5 segments of 2 miles each. As I have mentioned in previous posts, I like to do this because it not only breaks up the monotony, but it gives me a better indication of my pace that I am currently working on since I have my watch set up to display the pace for the current leg. I find this to be a much more credible reading than trying to find a current pace that will jump all over the place due to GPS anomalies, and I'm sure a few other reasons.
Coming off the weekend's long run that was only 3 miles longer, I suppose this run could have felt like as much work as that one did. The difference here though was that I wasn't going to get quite up to marathon pace, which for me is around 9 minute miles. The other factor that might have worked its way into the equation was the fact that it was 63 degrees when I started my run...a full 10 degrees cooler than Sunday. I ended up running the 2 mile legs all around the same pace...closer to the fast end of the range, and finished with an overall pace of 9:31. I even had a leg where I lost track of my time and ended up with a 9:23 pace for miles 5 and 6.
If it sounds like I'm obsessed with numbers and paces, you might be on to something. It's this fact that keeps me sort of motivated, but I also know that pace and times aren't the only thing. In fact, I was reading today about running in the summer, and the effects the heat and humidity have on performance, and it was actually encouraging. I'm really hoping for the summer months to help condition me well, and I will be that much more ready for Chicago in October.
While I have never been really "down" about training, there are always some highs and lows. Today was certainly a high for me. I honestly felt like I could run a dozen more miles at the end of the run, and I was tempted to speed my pace during the run, but I am trying to stick to training paces based on my marathon goal pace. Tomorrow is a recovery run, and then I have a much more challenging workout on Thursday. If I had overdone it today, it's likely that I would not be as ready for Thursday, so I had enough discipline to keep my ego in check.
Did I mention that today was a good day?
Coming off the weekend's long run that was only 3 miles longer, I suppose this run could have felt like as much work as that one did. The difference here though was that I wasn't going to get quite up to marathon pace, which for me is around 9 minute miles. The other factor that might have worked its way into the equation was the fact that it was 63 degrees when I started my run...a full 10 degrees cooler than Sunday. I ended up running the 2 mile legs all around the same pace...closer to the fast end of the range, and finished with an overall pace of 9:31. I even had a leg where I lost track of my time and ended up with a 9:23 pace for miles 5 and 6.
If it sounds like I'm obsessed with numbers and paces, you might be on to something. It's this fact that keeps me sort of motivated, but I also know that pace and times aren't the only thing. In fact, I was reading today about running in the summer, and the effects the heat and humidity have on performance, and it was actually encouraging. I'm really hoping for the summer months to help condition me well, and I will be that much more ready for Chicago in October.
While I have never been really "down" about training, there are always some highs and lows. Today was certainly a high for me. I honestly felt like I could run a dozen more miles at the end of the run, and I was tempted to speed my pace during the run, but I am trying to stick to training paces based on my marathon goal pace. Tomorrow is a recovery run, and then I have a much more challenging workout on Thursday. If I had overdone it today, it's likely that I would not be as ready for Thursday, so I had enough discipline to keep my ego in check.
Did I mention that today was a good day?
Labels:
Chicago Marathon,
exercise,
marathon,
running,
training
Monday, June 20, 2016
Training Day 14
Day 14 was a Marathon Pace Medium Long Run. The idea is to run at a slower pace for the first several miles, in this case the first 5, and then finish at marathon pace.
It has been a while since I have run for any length of time around 9 minute miles, so I knew it wasn't going to be easy. Factoring in the temperature and humidity, along with the hills along the route, it was going to be that much harder. And it was! After my initial 5 miles, I was able to easily keep the pace right around 9:00 for the first of 4 two-mile legs. The second was just outside the 9:10 limit I had programmed into my watch. (9:12) I fell off even further on miles 10 and 11 with a 9:23 average, and then finished the final uphill miles at 10:03 pace.
I'm not really worried too much about not making the goal paces this early in my training. I know that it was hard to do keep some of the paces early in training for my first half-marathon, so I've been here before. I would feel much better if I was training in cooler temps though. This is brutal weather for running, so I have to get up early in the morning.
I think for next Sunday, I'm going to try for a bit less hills for the long run. I also have to remember to bring something along to eat. I was wearing my hydration belt with 4 bottles of Gatorade, but my wife had made these oatmeal/banana/chocolate chip cookies, and I just forgot to take a few with me. As the long runs get longer, I'm really wanting to have something along to keep myself energized.
I went to the gym later in the day and did a bit of stretching, and as normal, I'll take Monday off with the exception of taking a walk with my son's dog. Two weeks down, 16 to go!
It has been a while since I have run for any length of time around 9 minute miles, so I knew it wasn't going to be easy. Factoring in the temperature and humidity, along with the hills along the route, it was going to be that much harder. And it was! After my initial 5 miles, I was able to easily keep the pace right around 9:00 for the first of 4 two-mile legs. The second was just outside the 9:10 limit I had programmed into my watch. (9:12) I fell off even further on miles 10 and 11 with a 9:23 average, and then finished the final uphill miles at 10:03 pace.
I'm not really worried too much about not making the goal paces this early in my training. I know that it was hard to do keep some of the paces early in training for my first half-marathon, so I've been here before. I would feel much better if I was training in cooler temps though. This is brutal weather for running, so I have to get up early in the morning.
I think for next Sunday, I'm going to try for a bit less hills for the long run. I also have to remember to bring something along to eat. I was wearing my hydration belt with 4 bottles of Gatorade, but my wife had made these oatmeal/banana/chocolate chip cookies, and I just forgot to take a few with me. As the long runs get longer, I'm really wanting to have something along to keep myself energized.
I went to the gym later in the day and did a bit of stretching, and as normal, I'll take Monday off with the exception of taking a walk with my son's dog. Two weeks down, 16 to go!
Labels:
Chicago Marathon,
exercise,
marathon,
running
Saturday, June 18, 2016
Training Day 13
Training Day 13 was a recovery run of 5 miles. It's hard to believe that after a year of running, 5 miles has become a run that is essentially a day off. Last year around this time, I was pumping myself up the night before to go out and try to go 5 miles. It didn't take long to build endurance for longer runs, but I remember having to stop before 5 miles because I was starting to get blurred vision because of the heat. Of course, I learned my lesson and now try to get my run in before the sun comes up...or as much of it as I can anyway.
Yesterday I did a bit or strength training at the gym for TD 12, so today I decided to take it easy after the recovery run. I spent most of my Saturday at my computer teaching myself MEAN stack development, so I should be pretty rested for my run in the morning.
The run in the morning is a Marathon Pace run of 13 miles...with the last 8 miles being at my marathon pace. Last Sunday's run was a mile shorter, and I would have really had to work hard to keep my marathon pace toward the end of that run...particularly the last few miles where there is some uphill. I'll be ending this one the same way, so I'll consider it a challenge.
Yesterday I did a bit or strength training at the gym for TD 12, so today I decided to take it easy after the recovery run. I spent most of my Saturday at my computer teaching myself MEAN stack development, so I should be pretty rested for my run in the morning.
The run in the morning is a Marathon Pace run of 13 miles...with the last 8 miles being at my marathon pace. Last Sunday's run was a mile shorter, and I would have really had to work hard to keep my marathon pace toward the end of that run...particularly the last few miles where there is some uphill. I'll be ending this one the same way, so I'll consider it a challenge.
Labels:
Chicago Marathon,
exercise,
marathon,
running
Subscribe to:
Posts (Atom)