|
epswing posted:DevOps comes with X free seats (I think 5?), beyond which the admin needs to pay for additional seats. Unless they’re VS subs in which case there’s no charge. If you needed to provide your own VS sub I’d guess your client didn’t want to pay for your seat, which was my dilemma above. I actually don't know if it was my management or the client that provided the sub but that makes sense.
|
# ? Feb 5, 2022 01:36 |
|
|
# ? Jun 6, 2024 15:30 |
|
epswing posted:I think you got the story backwards, I'm the employer. The "you" you're describing is the developer, as far as I can tell. Oh, yeah. I had it backwards.
|
# ? Feb 5, 2022 02:40 |
|
epswing posted:At least, that’s my understanding, I’m still new at DevOps, we’ve been using it for less than a year. Be aware that Microsoft is not investing in Azure Devops anymore and the guidance I've been seeing is basically "use github" with asterisks for a few scenarios around project management, manual testing, or integration with other git providers like bitbucket. IMO for enterprise usage Azure devops is superior in most ways but that's the way the wind is blowing at Microsoft.
|
# ? Feb 5, 2022 02:44 |
|
man I still have such issues with EF and saving related entities. I just don't get it at all. I have a couple of related classes like this: C# code:
C# code:
SQLite Error 19: 'UNIQUE constraint failed: Filter.Id'. Because for some reason it's trying to insert the Filter as a new row even though it already exists. So then I think ok, maybe I need to attach the Filters in the db to the current context so that it doesn't try to insert duplicates? Like this: C# code:
"The instance of entity type 'Filter' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked." I think this is because the context now has two versions of the same Filter object: one from the DB and one attached to the Playlist object. How can I tell the context that they're the same object?? The only way I can get it to work is like this, by actually changing the Playlist's Filter to the DB version: C# code:
e: actually I just realised my "solution" doesn't work anyway because it's not actually gonna save any changes to the Filter lol, just revert it back to the DB version fuf fucked around with this message at 16:28 on Feb 5, 2022 |
# ? Feb 5, 2022 16:02 |
|
fuf posted:man I still have such issues with EF and saving related entities. I just don't get it at all. Assuming this is EF Core, you're on the right track. You can re-attach the Filter object with DbContext.Update(): C# code:
No Pants fucked around with this message at 17:14 on Feb 5, 2022 |
# ? Feb 5, 2022 17:11 |
|
Thank you, that's helpful. I actually took a hammer to the problem and ignored the official Blazor advice to use a separate dbcontext for every operation. I replaced the dbcontextfactory with just a single dbcontext and it has basically solved all of my problems because now the context is just keeping track of everything. Maybe it will cause loads of other problems down the line but we'll see... I think the Blazor advice is because they assume you will be doing db operations within components, but I have all my db stuff in a separate service so maybe it'll be ok...
|
# ? Feb 5, 2022 18:20 |
|
fuf posted:Thank you, that's helpful. fuf posted:man I still have such issues with EF and saving related entities. I just don't get it at all. The problem in the first one is that you didn't load the Filter from database but rather created a new Filter object and added it to the navigation property without attaching it to the context. Since it doesn't exist in the context, the change tracker believes it's something new and tries to INSERT. That can be solved by using Attach(), as you did in the second example, but that errors out if the context already had it attached as from a previous operation. You correctly understood the problem in the second example: you loaded every filter from database, but then instead of picking out the filter from the loaded list that DbContext already knows of, you tried to attach your own untracked filter. For the third case, it's easier if rather than using Where().FirstOrDefault() (which will always load from database, btw), you can use Find() to get the entity from the context (or query the DB if it wasn't already loaded). The correct method to add a preexisting related entity to a new object is to: 1) Obtain your related entity from the context, usually through Find(). 2) Add that entity object to the navigation property. Also do whatever updates you wanna do to it. 3) Save. That said, sometimes you don't want to load a whole entity when a simple attach would work just fine. For that case, I made an extension method. C# code:
(Incidentally this is one of the reasons why you limit your DbContext to a single unit of work) Kyte fucked around with this message at 20:06 on Feb 5, 2022 |
# ? Feb 5, 2022 20:01 |
|
New Yorp New Yorp posted:Be aware that Microsoft is not investing in Azure Devops anymore and the guidance I've been seeing is basically "use github" with asterisks for a few scenarios around project management, manual testing, or integration with other git providers like bitbucket. Yeah, but it will take a good 5+ years for GitHub to catch up to all that ADO can accomplish. This means we are going to have 5 more years of stagnation, during which any investments to improve ADO are deferred and GitHub remains not ready for serious enterprise usage
|
# ? Feb 5, 2022 20:20 |
|
Kyte posted:That said, sometimes you don't want to load a whole entity when a simple attach would work just fine. For that case, I made an extension method. What kind of NRE, do you mean like null lists of children references? Isn't the correct thing to initialise those in the entity's constructor? And/or pass in an (optional) Action<TEntity> init to FindTrackedOrAttach to initialise the entity if it is created during the call.
|
# ? Feb 5, 2022 22:00 |
|
fuf posted:man I still have such issues with EF and saving related entities. I just don't get it at all. I "cheat" to get around this. I have 2 attributes: C# code:
C# code:
This works because all of the UI stuff deals with DTO objects not entity objects, and there is a services layer that sits between the UI layer(s) and the data access layer. The service layer converts from DTO objects to entity objects before calling methods in the repositories, so the repositories are free to mutate the entity object without fear of impacting the UI layer(s). Also, the DbContext is as ephemeral as I can possibly make it. This is hard on dependency injection because a Service needs an instance of a Repository which needs an instance of the DbContext, so if I inject a service directly into a viewmodel or controller, it leads to problems with the tracker, so I end up having to inject a ServiceFactory and creating services for single operations to make sure the DbContext doesn't outlive its usefulness. I've tried all the methods I've found on the net to deal with the tracker, like setting the State to "detached", or checking if it's tracked already before attaching an entity, and I haven't found any that work reliably. I've stepped through code that sets the state to "detached" only to check the context and see that the state is "unchanged". The only thing I've been able to get work reliably is Create DbContext -> perform ONE operation or transaction -> destroy DbContext. In my newest project, I'm actually going back to ADO.NET and rolling my own minimal ORM just to see how much fun it is. Sure, I won't have LINQ, but I can hand craft all the SQL.
|
# ? Feb 5, 2022 23:17 |
|
LongSack posted:
That's called Dapper. Try it out.
|
# ? Feb 6, 2022 00:03 |
|
New Yorp New Yorp posted:That's called Dapper. Try it out. Just starting, and haven’t gotten to that point yet. I’m very aware of Dapper (Tim Corey is a big fan), but I’m starting with the creation of the database and tables from the entity classes, which I don’t think Dapper handles. Dapper is definitely on my radar though.
|
# ? Feb 6, 2022 00:20 |
|
TheBlackVegetable posted:What kind of NRE, do you mean like null lists of children references? Isn't the correct thing to initialise those in the entity's constructor? Also I used to be lazy about adding collection initializers to my entity classes because EF takes care of it when it loads an entity. I meant stuff like, say you have an application form for, dunno, social media or whatever. And there's a dropdown to select countries. You received in your viewmodel the country IDs, so you do something like: C# code:
LongSack posted:Also, the DbContext is as ephemeral as I can possibly make it. This is hard on dependency injection because a Service needs an instance of a Repository which needs an instance of the DbContext, so if I inject a service directly into a viewmodel or controller, it leads to problems with the tracker, so I end up having to inject a ServiceFactory and creating services for single operations to make sure the DbContext doesn't outlive its usefulness. Isn't this what transient or scoped dependencies are for? (DbContext is scoped by default) Or you like them to be even more short-lived than per-request? Kyte fucked around with this message at 04:39 on Feb 6, 2022 |
# ? Feb 6, 2022 04:37 |
|
LongSack posted:Just starting, and haven’t gotten to that point yet. I’m very aware of Dapper (Tim Corey is a big fan), but I’m starting with the creation of the database and tables from the entity classes, which I don’t think Dapper handles. Dapper is definitely on my radar though. NPoco does table creation with a plug-in, and can use LINQ. It's pretty efficient.
|
# ? Feb 6, 2022 05:54 |
|
LongSack posted:Just starting, and haven’t gotten to that point yet. I’m very aware of Dapper (Tim Corey is a big fan), but I’m starting with the creation of the database and tables from the entity classes, which I don’t think Dapper handles. Dapper is definitely on my radar though. I recently discovered .dacpac, dunno how I messed it for so long but that poo poo looks pretty neat to me.
|
# ? Feb 6, 2022 10:18 |
|
Kyte posted:Isn't this what transient or scoped dependencies are for? (DbContext is scoped by default) It’s not really an issue with web apps, where a controller is being instantiated for a single request anyway - get me a list of Foos, update this Bar, delete this Dongle. But in a desktop app, where you say go to the account type maintenance window, and can create / update / delete account types all in the same window with the same ViewModel, then the DbContext tracker can get in the way.
|
# ? Feb 6, 2022 13:43 |
|
EssOEss posted:For the third case, it's easier if rather than using Where().FirstOrDefault() (which will always load from database, btw), you can use Find() to get the entity from the context (or query the DB if it wasn't already loaded). LongSack posted:I loop through all the public instance properties, and if any has the NullOnInsertOrUpdate attribute I set those properties to null before inserting up updating the item. Thanks for these, both very useful tips. I am back to using the dbcontextfactory and creating a context for each operation, because it seems like it'll save problems in the long run. Then I use a (way clunkier) version of LongSack's approach and null any properties I don't wanna save, do the db stuff, then set them back to their original values. For the db stuff, I check the db for any related entities, and then either insert or update them first before updating the main entity. I think it's probably pretty inefficient and overkill, but performance is very low on the list compared to getting something that works reliably.
|
# ? Feb 6, 2022 15:58 |
|
LongSack posted:It’s not really an issue with web apps, where a controller is being instantiated for a single request anyway - get me a list of Foos, update this Bar, delete this Dongle. Ah, makes sense. You mentioned controllers and viewmodels so I assumed you were talking web. Yeah, for desktop it makes much more sense to use a factory.
|
# ? Feb 7, 2022 01:42 |
|
I am trying to handle Python-style printf formatting. I could just write a parser for this but I wonder if this might be one I can do in one (albeit kind of gross) regex. The syntax if you're curious. I feel like I could get the basics with just basic IndexOf to find % signs and gun it from there but I know it'll be quite a bit of coding. I wondered if it would make any sizable difference over a compiled regex. Of course, if the regex multiplies, it would hit my threshold for "write a parser god drat" (usually at four regexes) regardless.
|
# ? Feb 7, 2022 09:08 |
|
I had to do something very similar and I just wrote a FSM using StringBuilder.Append(char). Haven't had any issues and the performance has been fine, considering it's a very hot path (I use it for most logging). There are just three states: PlainText, PrintfParam, JustAfterPrintfParam.
|
# ? Feb 7, 2022 09:35 |
|
Rocko Bonaparte posted:I am trying to handle Python-style printf formatting. I could just write a parser for this but I wonder if this might be one I can do in one (albeit kind of gross) regex. What I’m curious about is what’s missing from C# string formatting? Or is this just for fun?
|
# ? Feb 7, 2022 13:08 |
|
Potassium Problems posted: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. I missed that the generated class/function was static. Makes sense semantically, of course, but still I just injected it into a property manually in Startup: C# code:
New Yorp New Yorp posted:Be aware that Microsoft is not investing in Azure Devops anymore and the guidance I've been seeing is basically "use github" with asterisks for a few scenarios around project management, manual testing, or integration with other git providers like bitbucket. I've heard that it's going to be maintained in parallel. I mean, the Windows team apparently uses it so it's load bearing.
|
# ? Feb 7, 2022 17:39 |
|
Munkeymon posted:I've heard that it's going to be maintained in parallel. I mean, the Windows team apparently uses it so it's load bearing. Yeah but maintained in Microsoftese means "limited new feature development, if any". The bulk of the team was moved to GitHub a few years ago.
|
# ? Feb 7, 2022 18:16 |
|
Munkeymon posted:I've heard that it's going to be maintained in parallel. I mean, the Windows team apparently uses it so it's load bearing. Visual Studio uses it too but... New Yorp New Yorp posted:Yeah but maintained in Microsoftese means "limited new feature development, if any". The bulk of the team was moved to GitHub a few years ago. Yeah, this.
|
# ? Feb 7, 2022 18:54 |
|
I'm trying to get my head around something probably really basic.C# code:
Without having to explicitly do TagsOnPage = FilteredTags each time. If that makes any sense...
|
# ? Feb 8, 2022 16:35 |
|
New Yorp New Yorp posted:Yeah but maintained in Microsoftese means "limited new feature development, if any". The bulk of the team was moved to GitHub a few years ago. To be fair, GitHub's CI stuff has a lot of catching up to do
|
# ? Feb 8, 2022 16:54 |
|
fuf posted:I'm trying to get my head around something probably really basic. Why do you need to do this? What are you trying to achieve?
|
# ? Feb 8, 2022 17:24 |
|
Hammerite posted:Why do you need to do this? What are you trying to achieve? TagsOnPage is a list of tags that sometimes has its own list and sometimes just refers to FilteredTags. When it is just referring to FilteredTags I want to be able to change the FilteredTags list and have that change reflected in TagsOnPage (because they are the same list in that instance). Sorry if I'm not explaining properly...
|
# ? Feb 8, 2022 17:35 |
|
Use a method called GetTagsOnPage() and conditionally return which list you need?
|
# ? Feb 8, 2022 17:51 |
|
Yep, what you described as TagsOnPage isn't a value, it's a method that might return one of two values, value A when it's defined or value B when value A is missing.C# code:
|
# ? Feb 8, 2022 18:38 |
|
epswing posted:What I’m curious about is what’s missing from C# string formatting? Or is this just for fun? I'm implementing Python % operator in a personal interpreter project so I'm having to accept printf-like formatting operators. NihilCredo posted:I had to do something very similar and I just wrote a FSM using StringBuilder.Append(char). Haven't had any issues and the performance has been fine, considering it's a very hot path (I use it for most logging). There are just three states: PlainText, PrintfParam, JustAfterPrintfParam. Yeah I gave up and aimed for similar just because that regular expression smelled like an abandoned rake factory and I'd wind up in contortions dealing with something yet to be determined.
|
# ? Feb 8, 2022 19:47 |
Rocko Bonaparte posted:I'm implementing Python % operator in a personal interpreter project so I'm having to accept printf-like formatting operators. It's a mini language inside the language, just write a parser for it. You can try making it compile/translate to the .NET format string language if you think that's easier, just consider the impact for being able to accurately report errors.
|
|
# ? Feb 8, 2022 23:37 |
|
insta posted:Use a method called GetTagsOnPage() and conditionally return which list you need? NihilCredo posted:Yep, what you described as TagsOnPage isn't a value, it's a method that might return one of two values, value A when it's defined or value B when value A is missing. Yeah ok, thanks. I thought I was trying to do something clever but that makes sense. One thing I'm realising about Blazor is that it's relatively easy to make changes filter though to components, but it's actually kind of a pain to trigger methods within components. Like something like this: C# code:
OnInitialized means it wouldn't reflect the creation of a CustomTags List that happens during the component's lifetime. OnParametersSet would work but it fires after a change in any of the component parameters (including EventCallback's triggered by the component itself) so it seems kind of inefficient. The other option which I'm ending up using a lot is moving methods into a separate service, which is fine but it interrupts the neatness of having everything packaged into a single neat little component.
|
# ? Feb 9, 2022 15:31 |
|
fuf posted:One thing I'm realising about Blazor is that it's relatively easy to make changes filter though to components, but it's actually kind of a pain to trigger methods within components. Either I didn't understand your post, or you didn't understand the point of a getter like that. You don't "trigger" it on any particular event. You don't call TagsOnPage() to set or update anything. Rather, whenever another component needs to access the list of tags on the page, it invokes TagsOnPage() every single time, so it always reflects the presence/absence of CustomTags. A function call and a null-coalescing operator costs effectively nothing.
|
# ? Feb 9, 2022 17:30 |
|
Given the usage pattern, wouldn't it make more sense to make it a property?C# code:
|
# ? Feb 9, 2022 18:22 |
|
Kyte posted:Literally the same minus the parentheses. Not all properties are autoprops. Sure, it's a style choice. One practical consideration might be that a lot of reflection-based tooling looks at properties but ignores methods. E.g. serializers, designers, data binders, ORMs. So if you want them to "see" TagsOnPage, make it a property; if you want them to ignore it, make it a method (you could also look up the right attribute to make them ignore it, but making it a getter method works every time on all such tools, although it's less explicit).
|
# ? Feb 9, 2022 18:31 |
|
NihilCredo posted:Either I didn't understand your post, or you didn't understand the point of a getter like that. Yeah sorry my bad, I wasn't actually looking at your code properly. Using a getter like that (either as a method or a property) does actually look like it could help. Man there's still so much basic stuff I don't know. This is the problem with doing like one day of courses on LinkedIn Learning and then just jumping in. I think I need to go back to doing some courses soon now that I have a sense for what the actual problems are and why the solutions are good solutions.
|
# ? Feb 9, 2022 19:26 |
|
I've got a WPF .NET Framework application that needs to be distrubuted externally. Previously I just published it on an internal network share with ClickOnce, and auto-update just took care of itself. Any ideas on what the cleanest, most reliable way to do this is? We've got a sharepoint site that the external parties have access to, was thinking of hosting the files there. Not sure how well that would work with the ClickOnce auto-update though? I considered hosting it on Azure blobs, but whenever setup.exe is downloaded from there, most anti-virus's throw a fit at having to run it. I could probably spin up an instance of IIS for it, but that feels like overkill. Using Squirrel + Github involves downgrading to .NET Framework 4.6.1, which I'm not sure what knock-on effects that'll have. Maybe I'm over complicating this!? Any ideas?
|
# ? Feb 16, 2022 04:46 |
|
A github page, perhaps?
|
# ? Feb 16, 2022 11:16 |
|
|
# ? Jun 6, 2024 15:30 |
|
riichiee posted:I've got a WPF .NET Framework application that needs to be distrubuted externally. I currently do this by publishing the app to an Amazon S3 bucket, but that'll probably give you the same issue as using an Azure blob solution. Are you signing the ClickOnce manifests? Pretty sure our users only have to explicitly allow it on the first install, after that it just runs/updates without issue.
|
# ? Feb 16, 2022 13:29 |