I wanted to play around with Async in a console app, but most of the examples are in either winforms or mvc.
I found this article that showed exactly how to do it! Posting it to get it more coverage and so that I can get back to it if needed.
Thursday, May 21, 2015
Thursday, April 23, 2015
Add / Get Query Value from Uri Extension Method
Needed to pull some code from an older project that had an interesting utility. It had extension methods for adding and retrieving values from a Uri query string.
I thought that was neat so I wrote my own version.
I thought that was neat so I wrote my own version.
Wednesday, April 15, 2015
Angular Html Literal Directive
Yes, this is not the way you're supposed to use Angular. There might be a better workaround out there.
I needed a way to generate image elements through Angular with custom attributes, including classes and styles. I'm working in a legacy system that makes this difficult. Can't use curly braces because we need to keep using the dead jQuery Tmpl, hasn't been phased out yet. I couldn't make the angular bindHtml directive to work. It kept on removing my style and class attributes.
So I came up with this...
I needed a way to generate image elements through Angular with custom attributes, including classes and styles. I'm working in a legacy system that makes this difficult. Can't use curly braces because we need to keep using the dead jQuery Tmpl, hasn't been phased out yet. I couldn't make the angular bindHtml directive to work. It kept on removing my style and class attributes.
So I came up with this...
Monday, March 23, 2015
Angular Comparison Validation
Ahh, Angular... Why can't your documentation be as good as what I find on StackOverflow?
Thank you, Bernard Loureiro for the code sample! From that I was able to put this together.
This directive allows you to compare two different fields on your model. The compareOperator property is really cheesie right now. If it is set, it checks to see if there's an equals and/or a greater than sign. If not, it ignores it. To make that more robust, I'd need to give some good error messages, add some documentation, etc... It works for my needs right now.
Thank you, Bernard Loureiro for the code sample! From that I was able to put this together.
This directive allows you to compare two different fields on your model. The compareOperator property is really cheesie right now. If it is set, it checks to see if there's an equals and/or a greater than sign. If not, it ignores it. To make that more robust, I'd need to give some good error messages, add some documentation, etc... It works for my needs right now.
Monday, March 16, 2015
Escaping Text for CSV in TSQL
Needed string fields output in CSV, but with punctuation being used, that can be crazy. Figured it out, at least for the cases I'm looking at.
SELECT
cr.Id
,'"' + REPLACE(cr.Description, '"', '""') + '"' AS Descrption
,'"' + REPLACE(rr.Response, '"', '""') + '"' AS Response
,'"' + REPLACE(rr.Reason, '"', '""') + '"' AS Reason
,cr.ResolvedDate
FROM Reviews cr
LEFT OUTER JOIN Responses rr ON cr.Id = rr.ReviewId
ORDER BY cr.Id, rr.Id DESC
SELECT
cr.Id
,'"' + REPLACE(cr.Description, '"', '""') + '"' AS Descrption
,'"' + REPLACE(rr.Response, '"', '""') + '"' AS Response
,'"' + REPLACE(rr.Reason, '"', '""') + '"' AS Reason
,cr.ResolvedDate
FROM Reviews cr
LEFT OUTER JOIN Responses rr ON cr.Id = rr.ReviewId
ORDER BY cr.Id, rr.Id DESC
Wednesday, February 4, 2015
PrismJS - Code Formatter for blogs
Note to self: Use this when you eventually get around to styling this blog!
http://prismjs.com/
http://prismjs.com/
Tuesday, February 3, 2015
MVC Routing and Areas - Can't find your view?
MVC Routing is weird...
We're refactoring an app to use Areas to break up our app into more manageable pieces. I moved some controllers to the new "Internal" area and tried to access it. It couldn't find the controller by accessing ~/Internal/Controller, but my code would be hit if I did ~/Controller, even though the controller had been moved to the new Area.
Even when hit, it couldn't find the view by calling return View(model);
I added a new controller to the area controller's folder and used that namespace for my existing controller.
Now it works! However, my controller will still be hit if I call ~/Controller or ~/Internal/Controller.
MVC must look at the namespace to determine routing, which I think is unfortunate.
So, if you're having an issue with a controller you moved to an area, make sure you have the correct namespace!
We're refactoring an app to use Areas to break up our app into more manageable pieces. I moved some controllers to the new "Internal" area and tried to access it. It couldn't find the controller by accessing ~/Internal/Controller, but my code would be hit if I did ~/Controller, even though the controller had been moved to the new Area.
Even when hit, it couldn't find the view by calling return View(model);
I added a new controller to the area controller's folder and used that namespace for my existing controller.
Now it works! However, my controller will still be hit if I call ~/Controller or ~/Internal/Controller.
MVC must look at the namespace to determine routing, which I think is unfortunate.
So, if you're having an issue with a controller you moved to an area, make sure you have the correct namespace!
Subscribe to:
Posts (Atom)