|
It should work if you define the property as a nullable Guid, but you'd have to manually set it to null if you have an empty one. Don't know if there's some kind of mapping you could do in EF.code:
|
# ¿ Dec 3, 2014 22:12 |
|
|
# ¿ May 17, 2024 19:20 |
|
Small White Dragon posted:2) BitConverter uses the endianness of the machine it's on. Is there a way to use network byte order? I've always used something like this: code:
|
# ¿ Jul 17, 2015 23:08 |
|
CapnAndy posted:So today I learned that HttpWebResponse throws an error on 404 and you have to wrap the whole thing in try/catch and you can use the exception's response code in the catch segment. It also throws an exception on 304 Not Modified! I hated seeing "The remote server returned an error: 304 (Not Modified)" because the server wasn't in the wrong If you have the option, using HttpClient in System.Net.Http (.NET 4.5 I think?) is much better.
|
# ¿ Sep 8, 2015 22:28 |
|
Nope, the streams get disposed of when the code exits the using block (assuming you're not manually disposing of them in your methods). You're correct in that you need to start each Process method with a seek on the input stream back to its beginning, assuming the streams support seeking. Edit: whoops, you're right, you need to get rid of the using blocks in your Process methods. They'll kill the streams for sure. Potassium Problems fucked around with this message at 22:27 on Sep 9, 2015 |
# ¿ Sep 9, 2015 22:25 |
|
I'd recommend having them use MiniProfiler in their apps (http://miniprofiler.com/), which will show them issues with the queries EF generates, but to really fix this your devs are going to have to get a better understanding of SQL, and realize that just because the ORM generated a statement for you it doesn't mean it's good or correct. As far as tutorials, this one was published a couple days ago on the official asp.net site. edit- whoops, MVC 5 is definitely not beta, got mixed up Potassium Problems fucked around with this message at 16:56 on Oct 29, 2015 |
# ¿ Oct 29, 2015 16:53 |
|
The Wizard of Poz posted:I have an MVC5 project that I'm working on that, after receiving a file upload, has to notify a person by email that the upload has occurred. I want to hand this off to a separate process so that the user can get the HTTP response back and continue on their way without waiting for the email to send, since it's not a critical part of the process from the user's point of view and there's no reason they should wait. I've been using Hangfire for stuff like this, and for scheduled tasks. example: code:
|
# ¿ Feb 24, 2016 00:50 |
|
ljw1004 posted:I wonder where other folks here get their "joy of coding" from? For me, a bottle of Maker's Mark
|
# ¿ Jan 19, 2017 08:09 |
|
Xeom posted:
Is this what you're asking for? code:
|
# ¿ Jul 28, 2017 01:17 |
|
Munkeymon posted:IIS is recycling the app pool. You have to keep it loaded in memory by hitting the site constantly with a script or configure IIS to only recycle if it leaks too much memory. In addition to this, you might want to look at the application initialization module for IIS, which will restart your site after a recycle
|
# ¿ Feb 13, 2018 22:22 |
|
Ciaphas posted:I guess the only thing I can think of is something like this: Wouldn't something like this work to avoid a nested try/catch? C# code:
|
# ¿ Apr 6, 2018 22:14 |
|
Shy posted:I'm pretty sure it appeared long time ago and asp.net propositions weren't there yet. yeah IIRC Nancy's been around since 2010, as a .NET answer to Sinatra
|
# ¿ May 17, 2018 07:47 |
|
They've added HttpClientFactory in .NET Core 2.1 (currently in preview/RC), in part to help devs deal with stuff like that https://blogs.msdn.microsoft.com/webdev/2018/02/28/asp-net-core-2-1-preview1-introducing-httpclient-factory/
|
# ¿ May 23, 2018 23:23 |
|
epalm posted:I'm considering rolling my own software licensing scheme. Among other things, the software, when sold, will be licensed to run on a particular computer. I'm looking for a resilient way to identify "a computer" (where the OS in my case will be one of Windows 7, 10, or Windows Server 2008, 2012, 2016). There's lots of literature recommending different ways to do this. Some common ones I don't like are... I've recently had to do this as well, I used this NuGet package to generate a unique machine id, which I believe just uses WMI under the hood anyway. It lets you include different device values to come up with a reasonably unique identifier, or implement your own device component if the built-in ones aren't enough. For my use case, it was acceptable to include only the motherboard serial, OS & MAC address, but these were for machines under our control and any spoofing/tampering with those values would be a larger problem. Edit: gonna also recommend https://keygen.sh/, software licensing as a service. Not free, so may not be an option.
|
# ¿ Nov 22, 2018 21:13 |
|
NihilCredo posted:Has anybody used Hangfire for background tasks? I saw it mentioned in a HN commenti and it looks pretty good, would save us a good chunk of boring code. Yep, been using it for a few years to run early morning tasks (update this, email that, etc) and it's worked like a charm.
|
# ¿ Dec 9, 2018 17:45 |
|
New Yorp New Yorp posted:I've worked at and consulted at enough places where NIH syndrome resulted in everyone struggling to use clunky bespoke software that poorly implements a subset of the functionality of any number of robust, SaaS offerings. Despite my objections, I authored and maintain a clunky bespoke time tracking / ticketing system at my job and this entire topic touches my very soul. Also more power to Long Sack, let he who has not written a blog throw the first exception
|
# ¿ Feb 7, 2019 21:48 |
|
LongSack posted:Am I the only one that finds it odd that you have to overload the '>=' and '<=' operators explicitly even if you overload '==', '<' and '>' already? Is there a reason for this besides "that's just the way it is"? I would imagine under the hood they are distinctly different operators (Equals, LessThan, LessThanOrEqualTo, GreaterThan ...) and are handled as such, and the `>=` & `<=` operators aren't just syntactic sugar, if that makes sense. I would find it odd you're overloading operators in the first place
|
# ¿ Feb 26, 2019 20:38 |
|
LongSack posted:Why is that surprising? Two Account objects are equal if they have the same AccountId whether or not the two objects are the same reference. And IComparable<T>, where it makes sense, is something like Like B-Nasty said, it easily leads to unclear code, and usually other devs (maybe even yourself, 6 months down the line) will have to dig into the overload code to see what the intent really is. I've seen really obtuse stuff from people who thought they were being super clever. Sanitized example: code:
Potassium Problems fucked around with this message at 21:27 on Feb 27, 2019 |
# ¿ Feb 27, 2019 21:25 |
|
Rocko Bonaparte posted:I'm trying to use some reflection to expose some C# functions in my toy language interpreter. It looks like I should extract a MethodInfo to get to parameter bindings, but it seems clumsy. Other than "That's just how the reflection APIs work" I dunno what to tell you, except you can and should use nameof instead of a magic string code:
|
# ¿ Mar 14, 2019 07:43 |
|
EssOEss posted:I look at golang's "compiles to a single exe" with envy! To be fair, you can sort of achieve that in .NET too by embedding the assemblies into the exe but it requires extra hassle (and I bet does not work with netcore). The ability to generate a single exe is going to be in. NET core 3 https://www.hanselman.com/blog/MakingATinyNETCore30EntirelySelfcontainedSingleExecutable.aspx
|
# ¿ Jun 22, 2019 20:48 |
|
Are you talking about an open generic? like typeof(List<>)
|
# ¿ Mar 8, 2020 20:56 |
|
New Yorp New Yorp posted:Your classes are too big and doing too much. it's this. also, the decorator pattern might help with concerns like logging.
|
# ¿ May 22, 2020 20:56 |
|
David Fowler tweeted about this the other day, I think this is what you're looking for? https://twitter.com/davidfowl/status/1484985441832951810?s=21
|
# ¿ Jan 26, 2022 17:50 |
|
Whoops, I completely missed the .NET 4.8 part. Sorry!
|
# ¿ Jan 26, 2022 20:12 |
|
Function method bindings are separate from the dependency injection container, if you want an available IConfiguration instance, you'll have to make it so that the class/function isn't static and inject IConfiguration into the class constructor
|
# ¿ Feb 4, 2022 23:18 |
|
I don't know what you mean, and maybe it's changed with .NET 5/6, but the way function parameter bindings happen (i.e., ILogger, Trigger-specific arguments like a service bus message or HTTP request object) isn't aware of the dependencies you wire up in Startup.cs, which is why the op is getting binding errors. You have to have a non-static function in a non-static class and wire up the constructor to take a dependency on IConfiguration.code:
|
# ¿ Feb 4, 2022 23:46 |
|
I want to say that returning a type that inherits from ObjectResult will ensure you don't have to materialize the list & will stream it to the client, but I don't know if that's true or not and I can't seem to find any documentation on itC# code:
Potassium Problems fucked around with this message at 18:59 on Jun 12, 2023 |
# ¿ Jun 12, 2023 18:57 |
|
epswing posted:Oops. Ok, so I'm playing around in LINQpad8 and it must be doing some magic, enough for me to question my entire existence as a developer for a few minutes there. Glad to hear I'm not crazy, this time. Huh, I wonder what LINQPad is doing behind the scenes, visual studio reports the expected output
|
# ¿ Apr 26, 2024 19:27 |
|
|
# ¿ May 17, 2024 19:20 |
|
Sounds like you want to implement multi-tenancy
|
# ¿ Apr 30, 2024 00:26 |