|
I am porting an iOS/Mac/Android app to Windows using WPF, and need a basic sanity check on our approach to dealing with the database. We are planning to use Entity Framework and SQLite to store the client-side data, which will then be displayed at runtime in various ListViews and TreeViews. It seems like the standard way of populating those ListViews and TreeViews is to use databinding, however it's not quite clear to me how to ensure that the ListViews/TreeViews continue to update when the EF objects they are bound to are updated/inserted/deleted in the database. In particular: 1. When the EF object itself has one of its properties changed, and I want the ListView to update with the new property. Searching on StackOverflow I get the impression that I would have to manually implement INotifyPropertyChanged for each property to get the bindings to fire, as the EF objects don't include this capability by default. Is this correct? 2. When one (or more) EF objects are updated in a background thread (that is syncing with a web service), what's the proper way to ensure those changes propagate to the UI? Because DbContexts aren't thread-safe, different contexts need to be used for populating the UI vs syncing in a background thread. Is there a way to merge changes from one DbContext to another? (On iOS/Mac, Core Data's NSManagedObjectContext supports both of these use cases, and Android's ContentProvider/CursorLoader/CursorAdapter does something similar, I am basically looking for the WPF equivalent, if there is one. Also, I'm not particularly attached to Entity Framework if there happens to be a better way to achieve this.)
|
# ? Aug 9, 2014 22:48 |
|
|
# ? May 22, 2024 08:07 |
|
Does anyone have a recommendation for a resource for learning F# for someone pretty familiar with C#?
|
# ? Aug 9, 2014 23:06 |
|
comedyblissoption posted:Does anyone have a recommendation for a resource for learning F# for someone pretty familiar with C#? if you have a pluralsight sub there are some good videos for both 'what the gently caress where are my curly braces' and 'okay how do i do anything useful with this'
|
# ? Aug 10, 2014 19:37 |
|
comedyblissoption posted:Does anyone have a recommendation for a resource for learning F# for someone pretty familiar with C#? There are a couple books with that very premise.
|
# ? Aug 10, 2014 22:37 |
|
I don't suppose someone could explain to me why my results for the arrays in this code are all System.Int32[]? It's probably something obvious but I am an idiot apparently. Done as a basic c# console program, trying to get it to print out (for two years as an example)... 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 Turns 1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2 Years 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12 Months code:
A Tartan Tory fucked around with this message at 05:25 on Aug 11, 2014 |
# ? Aug 11, 2014 05:23 |
|
I am not sure what you mean but:code:
|
# ? Aug 11, 2014 05:35 |
|
Mr Shiny Pants posted:I am not sure what you mean but: This wasn't it, but it did point me to what I was actually doing wrong. Nothing wrong with the arrays themselves, just how I was displaying them. Thanks for your help (I shouldn't learn to code at 5am in the morning). Changed to the following. code:
|
# ? Aug 11, 2014 05:37 |
|
A Tartan Tory posted:This wasn't it, but it did point me to what I was actually doing wrong. Nothing wrong with the arrays themselves, just how I was displaying them. Thanks for your help (I shouldn't learn to code at 5am in the morning). It wasn't clear what you were trying to do, but printing just the array will display the type: System.Int32 instead of the number of items it contains. Which is what you usually want.
|
# ? Aug 11, 2014 05:38 |
|
Mr Shiny Pants posted:It wasn't clear what you were trying to do, but printing just the array will display the type: System.Int32 instead of the number of items it contains. Which is what you usually want. Thanks for the tips, I still find it hard to spot idiotic things that I do when coding.
|
# ? Aug 11, 2014 05:44 |
|
A Tartan Tory posted:Thanks for the tips, I still find it hard to spot idiotic things that I do when coding. To be fair to you, this is one of the vast number of pitfalls and absurdities everyone encounters when learning. Why would the default ToString() behavior of any object be to print its type name? When is that ever useful? (hint: never).
|
# ? Aug 11, 2014 07:43 |
|
comedyblissoption posted:Does anyone have a recommendation for a resource for learning F# for someone pretty familiar with C#? I'd start with http://www.manning.com/petricek/ -- has parallel examples, and there are lots of tricks you can take back to your existing C# codebase from it.
|
# ? Aug 11, 2014 13:52 |
|
I've developed a custom WPF control that "intelligently" determines the best way to display information that's been bound to it. I want this control to expose a facility to export the data that's currently being displayed in a way that corresponds to the current way that information is being displayed. (i.e. the export format matches the display format). However, the control shouldn't be the component that actually initiates the export - that should happen elsewhere. What's the best way to do this? I was thinking of having the control offer some kind of Action<string> (or more appropriately, a custom delegate) property that a view model could bind to using OneWayToSource binding, but I'm not sure if that's the kind of thing I should be doing, or if it is, if there's a way to enforce the one-way-reverse behavior when setting up the relevant DependencyProperty. e: It looks like the "right" way to do this, using a ReadOnlyDependencyProperty, isn't going to work. raminasi fucked around with this message at 18:56 on Aug 11, 2014 |
# ? Aug 11, 2014 18:43 |
|
Can't you just have a dependency property representing the stringified value?
|
# ? Aug 11, 2014 18:55 |
|
Ender.uNF posted:To be fair to you, this is one of the vast number of pitfalls and absurdities everyone encounters when learning. Why would the default ToString() behavior of any object be to print its type name? When is that ever useful? (hint: never). On the contrary, it's very useful for telling me "hey moron, you need to do something with this object!"
|
# ? Aug 11, 2014 23:31 |
|
Ender.uNF posted:To be fair to you, this is one of the vast number of pitfalls and absurdities everyone encounters when learning. Why would the default ToString() behavior of any object be to print its type name? When is that ever useful? (hint: never). Yep, this one got me too. A Tartan Tory one thing that could have helped would have been to show us both the expected and the actual output, but that's neither here nor there now that the solution has been given. Just a head's up I guess.
|
# ? Aug 12, 2014 04:47 |
|
Ender.uNF posted:Why would the default ToString() behavior of any object be to print its type name? When is that ever useful? (hint: never). What else makes sense as a default, though?
|
# ? Aug 12, 2014 18:02 |
|
Fundamentally the point of .ToString() is to make sure you can call .ToString() on any object. Having the type name spit out is a reasonable behavior and gives a bit more information than having it say "Fix Me". If you call .ToString() on an int32 it will spit out the number. If you call it on the array it will spit out the fact it is a System.Int32[]. If you want to spit out the length perhaps you should call myarray.Length.ToString().
|
# ? Aug 12, 2014 19:07 |
|
So I'm attempting to track down a memory leak that I believe is related to an event handler, and I have a dumb question that shouldn't be that difficult to Google but apparently is (or maybe I am just bad at it). If I do the following:code:
|
# ? Aug 12, 2014 19:40 |
|
Scuzzywuffit posted:So I'm attempting to track down a memory leak that I believe is related to an event handler, and I have a dumb question that shouldn't be that difficult to Google but apparently is (or maybe I am just bad at it). If I do the following: Have you run a profiler? Red Gate's profiler (ANTS, I believe) is excellent at hunting this kind of thing down, and there's a free trial.
|
# ? Aug 12, 2014 20:12 |
|
Ithaqua posted:Have you run a profiler? Red Gate's profiler (ANTS, I believe) is excellent at hunting this kind of thing down, and there's a free trial. Yeah, I'm looking at it in dotMemory, which is how I found the handler in the first place. I have a window that's remaining in my application's window list even after I close it. dotMemory shows a reference to it from a RoutedEventHandler's _target property, which I'd been assuming was why it wasn't being removed and garbage collected.
|
# ? Aug 12, 2014 21:08 |
|
I have a .NET service with extremely unreliable and cumbersome end-to-end test automation so I'm trying to mock out some of the external dependencies to get things under control. One of them is a RESTful service that sends and receives data through JSON. One method is ReturnFoo and the request to the real service looks like this:code:
I have this mocked out in WCF like so: code:
code:
|
# ? Aug 13, 2014 01:57 |
|
Not sure how to solve your issue, but the reason it is occurring is probably because proper Json format forcode:
code:
Not sure if it'd work, but you could try receiving the request as a string instead of a List<string> and then at least see what you have to work with.
|
# ? Aug 13, 2014 03:36 |
|
Faldoncow posted:Not sure how to solve your issue, but the reason it is occurring is probably because proper Json format for Ah thanks, I have not worked much with JSON and didn't realize it wasn't even valid. Couldn't retrieve it as a string for the same reason but was able to retrieve it as a Stream and grab the raw bytes.
|
# ? Aug 13, 2014 04:05 |
|
Eggnogium posted:Ah thanks, I have not worked much with JSON and didn't realize it wasn't even valid. Couldn't retrieve it as a string for the same reason but was able to retrieve it as a Stream and grab the raw bytes. Use something like Json.net to serialize and deserialize you object to and from Json, it will save you a lot of trouble.
|
# ? Aug 13, 2014 05:29 |
|
I have a problem with an MVC action I'm trying to write. I want a model to be supplied as an optional parameter to the action so that the model can be fetched from TempData instead if there is no model supplied. So I have the following:code:
|
# ? Aug 13, 2014 06:45 |
|
Mr Shiny Pants posted:Use something like Json.net to serialize and deserialize you object to and from Json, it will save you a lot of trouble. The serialization is in a library I don't control. All I could do was modify the config to point at my mock service. Apparently the real service can (only?) handle the invalid JSON.
|
# ? Aug 13, 2014 07:40 |
|
Is ELMAH still supported? I was thinking of using this for a MVC project at work and the last time it got any sort of love was back in 2012, the lead developers here are leery of using it because of this. Or is there any sort of alternative to ELMAH?
|
# ? Aug 13, 2014 16:12 |
|
Servicestack.text (3.9 branch, 4 is pay to use) is pretty good for serializing/ deserializing stuff (XML/ JSON/ etc). I've used elmah and its fine but I mainly just use log4net. Elmah is fine as a general uncaught exception listing tool though. Just remember your permissions set for the page if this is public facing!
|
# ? Aug 13, 2014 16:44 |
|
So I realized that I forgot to cross post from project.log over to here. Being that it's a .NET specific project, I think that you guys will be more interested than goons in general http://forums.somethingawful.com/showthread.php?threadid=3657015
|
# ? Aug 13, 2014 16:49 |
|
I inadvertently clicked on "Enable .NET framework source stepping" in the debug/general menu and now although It's unclicked it still steps through everything I even exported the config file and verified that the option is set to 0, but still no dice. Using VS 2013.3, any suggestions?
|
# ? Aug 13, 2014 23:29 |
|
candy for breakfast posted:I inadvertently clicked on "Enable .NET framework source stepping" in the debug/general menu and now although It's unclicked it still steps through everything I even exported the config file and verified that the option is set to 0, but still no dice. Does this mean you get that annoying thing that says: Need source file for yadda yadda.cs? No help, I got the same error. Now I get to remember each time make a call to an external library. Really, really annoying.
|
# ? Aug 14, 2014 05:27 |
|
Re: ELMAH alternatives: I've used StackExchange.Exceptional and it's pretty good. Stacks repeated exceptions so it's easy to read but will throw away some info in that case (only keeps the http context data for the first one etc.). Less configurable than ELMAH but it's easy to throw custom data into it along with the exceptions. I haven't used it but I've heard good things about Serilog.
|
# ? Aug 14, 2014 14:58 |
|
Does anyone have any ideas about getting around SignalR's inability to have async event handlers? I'm working on something where I have my application's logic totally platform-agnostic and want to fire events when the internal state changes and needs to be pushed to clients, but SignalR can't handle async void methods.
|
# ? Aug 14, 2014 15:26 |
|
Ithaqua posted:Does anyone have any ideas about getting around SignalR's inability to have async event handlers? I'm working on something where I have my application's logic totally platform-agnostic and want to fire events when the internal state changes and needs to be pushed to clients, but SignalR can't handle async void methods. Does it have to be Async Void, or can it return a Task?
|
# ? Aug 14, 2014 15:35 |
|
Drastic Actions posted:Does it have to be Async Void, or can it return a Task? It's an event handler, so it can't return a Task. Let's say I have this pseudo-pseudocode: code:
[edit] Basically, I'm writing a multiplayer, multi-instance turn-based game. I want the game instances to fire events when certain actions occur internally (for example, "round timeout expired, anyone who hasn't played this round yet can get hosed") so the clients can be notified. I don't want to pass an instance of the HubContext into the game objects, because that would violate the poo poo out of separation of concerns -- the game should be responsible for maintaining its internal state, and the hub should be responsible for figuring out what data to push to connected clients based on how the game's internal state is changing. New Yorp New Yorp fucked around with this message at 16:06 on Aug 14, 2014 |
# ? Aug 14, 2014 16:03 |
|
The Wizard of Poz posted:I have a problem with an MVC action I'm trying to write. I want a model to be supplied as an optional parameter to the action so that the model can be fetched from TempData instead if there is no model supplied. So I have the following: The MVC framework is always going to attempt to model bind the parameter. By the time that the MVC framework realizes that a complex object wasn't provided in the context, it's already instantiated the object from the its default constructor. The framework doesn't reflexively look at the object it instantiated and determine that it should call Page1() instead of Page1(model) because all of the properties on the instantiated object are defaults. If you want that functionality you'll have to write your own model binder for your TestFormViewModel class. Assuming your TestFormViewModel class looks like this: code:
The first option would probably be your best bet. If you want to go the model binder route, here's a custom model binder that you could use: code:
|
# ? Aug 14, 2014 17:10 |
|
Ithaqua posted:Does anyone have any ideas about getting around SignalR's inability to have async event handlers? I'm working on something where I have my application's logic totally platform-agnostic and want to fire events when the internal state changes and needs to be pushed to clients, but SignalR can't handle async void methods. We're doing something similar to this, but are using a homegrown messaging abstraction (that we're later going to hook up to Azure pub/sub or a messaging queue). Instead of using C# events, we register for a message type with a callback.
|
# ? Aug 14, 2014 20:59 |
|
Mr Shiny Pants posted:Does this mean you get that annoying thing that says: Need source file for yadda yadda.cs? Yes, it happens all the loving time Probably going to uninstall/reinstall tomorrow and hope for the best.
|
# ? Aug 14, 2014 21:20 |
|
Ithaqua posted:It's an event handler, so it can't return a Task. Could you drop this out into a thread-safe helper class? That's how I've been working with hubs and I'm able to trigger async void events for timer ticks and such.
|
# ? Aug 14, 2014 21:23 |
|
|
# ? May 22, 2024 08:07 |
|
Ithaqua posted:It's an event handler, so it can't return a Task. Why not logically make the game a client of the hub, the same as regular clients? Maybe a special client or something. That way logically everything is the same and the hub is only responsible for routing messages to its subscribers and you can reuse the message passing infrastructure that you already use for the clients.
|
# ? Aug 15, 2014 00:08 |