|
RICHUNCLEPENNYBAGS posted:List<T> does preserve order though? IList<T> supports indexing by number so it would be very odd not to have stable order. If you have a List<T> in memory, the order will not change unless you tell it to. However, if you reload that entity from the database with EF and include that List<T> property, there are no guarantees on ordering.
|
# ? Jan 6, 2015 18:07 |
|
|
# ? Jun 7, 2024 02:09 |
|
Is that what they call object-relational mismatch?
|
# ? Jan 6, 2015 18:27 |
|
It's reasonable to use a list because query results are ordered. The mismatch is when you try to pretend that foreign key relationships are object references. I've found that treating a database as sets of tuples leads to cleaner code and better performance on the order of magnitudes.
|
# ? Jan 6, 2015 19:56 |
|
Forgall posted:Is that what they call object-relational mismatch? Somewhere along the line it will execute a SQL query to retrieve the data. A recordset is always unordered.
|
# ? Jan 6, 2015 20:05 |
|
Forgall posted:Is that what they call object-relational mismatch? I'd say so.
|
# ? Jan 6, 2015 21:40 |
|
Why is "order by" in sql then
|
# ? Jan 7, 2015 07:25 |
|
For a truly ordered list, the order would need to be explicitly saved in the database in a column. In an ORM when an entity is loaded, then the list property accessed lazily, the order stored in the database should be reflected in the list without having to issue an "order by". This is a feature standard in nHibernate, not sure about Entity Framework. When writing a projection though, you would need to specify your own ordering.
|
# ? Jan 7, 2015 11:43 |
|
Bognar posted:If you have a List<T> in memory, the order will not change unless you tell it to. However, if you reload that entity from the database with EF and include that List<T> property, there are no guarantees on ordering. Well, yeah, that's why I suggested ICollection<T>.
|
# ? Jan 7, 2015 14:19 |
|
This is kind of an implementation question, that I'm wondering how you guys would handle. I have to take a string up to 300 characters long and extract up to 5 values for it based on keywords in the string. Some of the values I'm matching are (always deepest level when present, e.g. I can use 'christian-crosses' but not its parent 'christian-symbols' or 'religious-symbols'): https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/icg/jewelry_item_classification_guide.html#dc_general_SubjectContent So the way I did it way back when, when I was only concerned with 3 or 4 of them, was just a bunch of IF...THEN statements like this: code:
One idea I thought of is to make a database table (Subjects) like so: code:
code:
code:
EDIT-You can ignore the special cases like month-birthstone and zodiac-sign since they're 'two step' processes that I already handle elsewhere Scaramouche fucked around with this message at 01:17 on Jan 8, 2015 |
# ? Jan 8, 2015 00:57 |
|
Are you always searching for whole words and not subsets of words? If so, you should use a HashSet<string> or Dictionary<string, string>. Build a dictionary with all of your matching strings as keys, and the hyphenated versions as the values. Split your input string into words, then check for the existence of a key in the dictionary matching each word. Dictionary lookup is constant time so it will be a lot faster than doing a bunch of String.Contains calls, but now you'll have to worry about getting exact matches.
|
# ? Jan 8, 2015 03:00 |
|
Bognar posted:Are you always searching for whole words and not subsets of words? If so, you should use a HashSet<string> or Dictionary<string, string>. Build a dictionary with all of your matching strings as keys, and the hyphenated versions as the values. Split your input string into words, then check for the existence of a key in the dictionary matching each word. Dictionary lookup is constant time so it will be a lot faster than doing a bunch of String.Contains calls, but now you'll have to worry about getting exact matches. I get what you're saying there, but I was hoping to use .Contains to cheat a bit on a regex style match so I don't have to make as many rows/keyword entries. For example .Contains("baseball") will match 'baseball', 'baseballs', 'baseball player', 'baseball glove', 'baseball hat', 'baseball bad', 'baseball pitcher', etc etc. I started the database table approach and have a first run with about 200 rows, but if I had to do exact match that would balloon up to at least 800-1000 when you take pluralization and other things into account. I also really can't split the input string very easily because it's not clear what to split on. For example split on space would work on 'dragon' but not 'star of david' or any other compound terms.
|
# ? Jan 8, 2015 03:09 |
|
Are you stuck with having to use the database directly? Because it sounds like you're trying to implement full-text search which you'd be better off using a tool that already does this like Lucene or elasticsearch, or an RDBMS that supports full-text search (I believe postgres has recently added support for this). They will support stemming, pluralization, etc out of the box. This is a problem with a huge amount of edge cases and natural language-aware logic that is gonna be pretty hard to get right yourself.
Dr Monkeysee fucked around with this message at 04:31 on Jan 8, 2015 |
# ? Jan 8, 2015 04:22 |
|
Any Azure gurus here? I have a strange situation. A while back I published an MVC4 app to Azure, ran it for a while, then recently decided to move to MVC5. Instead of "upgrading" to MVC5, because I know how upgrades usually go, I wiped out the MVC4 project entirely, added a fresh MVC5 project, copied over my controllers/views, and with minimal adjustments, everything worked locally. I then published the new project using the same Azure publish profile, and now I'm gettingquote:Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Some sort of assembly mismatch, which is exactly what I wanted to avoid. Is Azure holding on to some old reference/library? I'm publishing a basically brand new MVC5 project to Azure, why am I seeing assembly reference errors? Especially since the reference is looking for Razor 2, which is an MVC4 thing. Edit1: both System.Web.Razor and System.Web.WebPages.Razor have Copy Local set to True, in case that matters. Edit2: the internet told me to add the following to web.config to satisfy the reference, which I did code:
quote:Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Now DotNetOpenAuth.Core is definitely a pre-MVC5 thing (MVC5 is all Owin auth stuff). This makes me even more suspicious that something is hanging around in Azure that shouldn't be. epswing fucked around with this message at 07:29 on Jan 8, 2015 |
# ? Jan 8, 2015 07:10 |
|
The purpose of bindingRedirect entries is to tell the CLR that you are OK with loading a different version of an assembly than what is actually referenced. So if you have a dependency on v1.0.0.0 you can just tell it to use v2.0.0.0 and shut up about it. This is vital because you often cannot control what versions are referenced by various libraries you include (which may have been built against older but still compatible versions of other assemblies). The entry you added is generally the correct fix for that. Most NuGet packages add those entries automatically but sometimes they can get messed up. The later error simply means that some assembly that you are using still references the DotNetOpenAuth.Core assembly. Perhaps some library you use was built for MVC4? Whatever the case, you can simply tell it to use the version that is available. Alternatively, you may want to investigate what exactly is referencing it and see if any corrective action is needed there (e.g. update to a newer version of a library that does not reference it).
|
# ? Jan 8, 2015 08:30 |
|
here's an irritating vb.net parsing ambiguity: as parentheses are used for so many things, it can't compile this code:code:
code:
|
# ? Jan 8, 2015 11:58 |
|
EssOEss posted:Alternatively, you may want to investigate what exactly is referencing it and see if any corrective action is needed there (e.g. update to a newer version of a library that does not reference it). Thanks! How do I investigate what exactly is referencing it?
|
# ? Jan 8, 2015 17:04 |
|
.NET Reflector is my favorite tool for poking into assemblies. It provides a list of references for any assembly you open in it.
|
# ? Jan 8, 2015 17:19 |
|
Telerik's JustDecompile is pretty good too but by god if they aren't getting annoying with some of their nagware-like stuff. Hard to grouse about a free tool, but it used to be way less annoying
|
# ? Jan 8, 2015 18:22 |
|
http://ilspy.net/ also works great
|
# ? Jan 8, 2015 18:34 |
|
There's also dotPeek.
|
# ? Jan 8, 2015 18:45 |
|
Gul Banana posted:here's an irritating vb.net parsing ambiguity: as parentheses are used for so many things, it can't compile this code: F()() works.
|
# ? Jan 9, 2015 00:54 |
|
Dr Monkeysee posted:Are you stuck with having to use the database directly? Because it sounds like you're trying to implement full-text search which you'd be better off using a tool that already does this like Lucene or elasticsearch, or an RDBMS that supports full-text search (I believe postgres has recently added support for this). They will support stemming, pluralization, etc out of the box. This is a problem with a huge amount of edge cases and natural language-aware logic that is gonna be pretty hard to get right yourself. Yeah, I have access to our SOLR/Lucene install (it drives the search on our site) but didn't want to mess around with setting it up for this. I wasn't looking for a perfect solution, just a better one than the IF...THEN chain that I had going previously. The database solution is relatively elegant for the amount of effort involved, and if I want to add/remove/change it's just a simple INSERT/UPDATE away. It falls down for complicated cases (multiple negative keywords), but for multiple positive keywords I can just add rows (e.g. Boxer, Boxing). I've actually already repurposed it for some other similar attribute name -> attribute value relationships (by adding a Type column) for about 100,000 products.
|
# ? Jan 9, 2015 02:47 |
|
ljw1004 posted:F()() works. lol what I'd gone with F.Invoke(), so it's nice to have an alternative that doesn't betray the delegate-ness of the code - but how on earth is that parsed? one set of parens is the invoke, and the other.. a unit expression it's applied to? empty generic clause??
|
# ? Jan 9, 2015 04:51 |
|
ok, i've got it: VB.NET has indexed properties. you can write ReadOnly Property F(s As String) As String F("s") would invoke the getter. by analogy, you can call an UNindexed property like: F(). then the subsequent () are just the delegate invocation...
|
# ? Jan 9, 2015 10:51 |
|
Scaramouche posted:Yeah, I have access to our SOLR/Lucene install (it drives the search on our site) but didn't want to mess around with setting it up for this. I wasn't looking for a perfect solution, just a better one than the IF...THEN chain that I had going previously. The database solution is relatively elegant for the amount of effort involved, and if I want to add/remove/change it's just a simple INSERT/UPDATE away. It falls down for complicated cases (multiple negative keywords), but for multiple positive keywords I can just add rows (e.g. Boxer, Boxing). I've actually already repurposed it for some other similar attribute name -> attribute value relationships (by adding a Type column) for about 100,000 products. Is sql fulltext and option? That could get you there without messing about with SOLR.
|
# ? Jan 9, 2015 16:27 |
|
Jesus loving Christ. In a WPF application, I have an html string, and I want to render and display it to the user, and allow them to print what they see in landscape. Why is this the hardest loving problem in the history of problems on earth?
|
# ? Jan 9, 2015 18:09 |
|
epalm posted:Jesus loving Christ. In a WPF application, I have an html string, and I want to render and display it to the user, and allow them to print what they see in landscape. Why is this the hardest loving problem in the history of problems on earth? Now you know how St. Joseph of Sevastopol felt edit: \/\/\/ just some dude I made up ,but you can imagine him getting in quite the pickle. bpower fucked around with this message at 19:50 on Jan 9, 2015 |
# ? Jan 9, 2015 18:52 |
|
epalm posted:Jesus loving Christ. In a WPF application, I have an html string, and I want to render and display it to the user, and allow them to print what they see in landscape. Why is this the hardest loving problem in the history of problems on earth? I ended up punting that sort of thing to the browser when I had to try to figure it out a couple years ago
|
# ? Jan 9, 2015 19:17 |
|
bpower posted:Now you know how St. Joseph of Sevastopol felt I want to get this joke but Google is failing me
|
# ? Jan 9, 2015 19:33 |
|
WPF makes easy things hard and hard things easy.
|
# ? Jan 9, 2015 19:53 |
|
Inverness posted:WPF makes easy things hard and hard things easy. This is completely true. The dumbest part is, though, that with a product as old as WPF is now, they should have fixed all of those "hard" things ages ago. Example: Having control events that that can't simply data-bind to your view-model by default? Seriously, guys, WTF? Edit: Disclaimer, I am using 2012. Maybe they've fixed it since. (But I doubt it.)
|
# ? Jan 9, 2015 21:49 |
When I switched from winforms to WPF, my ability to estimate time on projects went way out of whack. Lots of stuff that I'd usually expect to take ages is trivial and easy and some stuff that seems really basic and easy is nigh impossible. It feels like a couple controls were just given up on. The Browser and Datagrid have both been nightmares to me at times. All things considered though, I loving love WPF after working with winforms for an unfortunately long time.epalm posted:Jesus loving Christ. In a WPF application, I have an html string, and I want to render and display it to the user, and allow them to print what they see in landscape. Why is this the hardest loving problem in the history of problems on earth? I had a similar problem where I was trying to display a formatted html version of various things my company works with. I ended up giving up and just going with a completely different solution where I didn't have to render HTML at all.
|
|
# ? Jan 9, 2015 23:58 |
|
I generally just gave up on WPF when trying to switch form WinForms, and went straight to MVC web apps.
|
# ? Jan 10, 2015 00:50 |
|
ljw1004 posted:F()() works. Oh, of course.
|
# ? Jan 10, 2015 02:07 |
|
This nice StackOverflow answer contains what VS 2012 files should typically be ignored by Mercurial. Among them is *.pubxml under the comment "## Publish Web Output". Makes sense, you don't want that sensitive information in version control. What comes along with your public profile however is a line in your csproj file like code:
Is there a nice way to handle this?
|
# ? Jan 10, 2015 19:26 |
|
Calidus posted:I generally just gave up on WPF when trying to switch form WinForms, and went straight to MVC web apps. This is what I did too. And now I'm further down the web rabbit hole with all the JS frameworks with Web API 2 backends.
|
# ? Jan 11, 2015 05:20 |
|
Let's say I have a standard EF backed MVC app, with the standard Product class, which has Name and Price properties. I've added the necessary annotations to indicate at the DB level that Name must be at most 40 characters, and Price must be greater than 0. I'm also doing The Right Thing by using Automapper to map Product objects to ProductEditDto objects for MVC consumption. In order to take advantage of client-side validation which spots problems right away and notifies the user via JS, I must also decorate ProductEditDto with a second set of annotations to ensure Name length and Price value are acceptable. Now I need to keep two sets of validation up to date. How do I avoid this?
|
# ? Jan 11, 2015 18:09 |
|
I have never found a non retarded way to do that, so good luck. In all my projects I simply end up with duplicate validation logic. I have tried various other approaches but they just turn the mess into a different type of mess in my experience.
|
# ? Jan 11, 2015 21:50 |
|
You could create custom validation attributes that implement your specific validation logic (e.g, NameMaxLengthAttribute which is really a MaxLengthAttribute(40)) and apply them to both your data models and view models. This means you have loads of sorta useless attribute classes floating around, but at least you wouldn't need to keep two sets of constants in sync.
|
# ? Jan 11, 2015 22:31 |
|
|
# ? Jun 7, 2024 02:09 |
|
I apologize in advance for sounding like an inexperienced moron. I am in the process of trying to upgrade all our in-house code from VB6 to VB.NET and since we're so small, no one really knows anything about visual Studio past VS99 or whatever was the last VB6 release. I am trying to catch up on the last 10-15 years of advances on my own. Why does it seem like everyone is making web apps as opposed to local apps? In my shop we have no need for any special internet applications outside of the browser and with HIPAA we have little to no reason to unnecessarily expose our data to the internet more than required. Am I mis-interpreting what MVC does?
|
# ? Jan 12, 2015 02:02 |