« first day (2185 days earlier)      last day (2757 days later) » 

12:06 AM
posted on October 08, 2016 by Scott Hanselman

I had a reader send me a question yesterday. She basically wanted to use her existing .NET Framework libraries in an ASP.NET Core application, and it wasn't super clear how to do it. I have a quick question for you regarding asp.net core. We are rewriting our website using asp.net core, empty from the bottom up. We have 2 libraries written in .net 4.6 . One is our database model and repositor

 
 
2 hours later…
2:25 AM
@Tomwa Oh man, that's one important little detail! No wonder MS has pushed so hard for users to upgrade.
@SeanStayn Yeah, I am looking forward to developing in it. UWP and Xamarin is quite the offering. Let's hope for everyone who has invested heavily in MS skills that it's successful.
 
 
1 hour later…
3:29 AM
anyone using mvc?
 
3:46 AM
lots of people are @AdanRamirez
 
 
2 hours later…
5:31 AM
Hi guys
I wanted to ask something for asp.net mvc
Is anybody currently active in this room ??
 
 
3 hours later…
8:23 AM
wouldn't it be nice if people would use something other than EF and blog posts in their MVC tutorials?
I don't know who started it but I'm starting to think that EF and MVC were created only for blog sites
that and TODO lists
 
I like to dapper~
 
me too :)
though at my last job we were using Dapper on top of OleDbConnection and it was buggy
because Dapper has optimizations that OleDb apparently does not support
which is really a problem with the .NET framework, not Dapper
but still....
 
but why oledb
 
shitty architect :)
not the current architect
but the one before him
 
good ;^)
 
8:35 AM
they wanted their code to run on both sql server and oracle db
 
oh that was the reason
 
so they used OleDb for everything
 
technically they were right
but in practice they shouldn't
 
technically they should have used a DbProvider abstraction
 
yes
 
8:36 AM
not rely on OLE
because as it turns out, OLE is a buggy piece of crap that needs to go away
 
well but you know essentially it was a good idea to have something like this
and it should "work"
but obviously there are huge differences
 
it could have worked but then they also hardcoded a bunch of queries that would never work on oracle db
so you have an OleDbConnection that can connect to any database
but the queries would only succeed on sql server
so lol
what is the point even
 
inexperience
 
being able to run on oracle db was never even a requirement for that project
so anyway our problems were twofold
1) the OLE provider is buggy and does not support some optimizations
2) Dapper is hardcoded to always enable optimizations
T_T
I'm so glad I quit that job :D
 
lol I know that feeling
I honestly have nightmares sometimes of my previous job
 
8:42 AM
it was a tough decision because the team that I was in was trying hard to make the best of what was already there
but when there is so much crap code, there isn't much you can do
 
but start over
 
9:01 AM
Hello everyone!
 
what's up steven!
 
refactoring some code
 
well I've question? do you think 2 or 3 years of experience guy can be a CTO of a company?
 
sure why not
 
9:15 AM
So should company/CEO expect less from young CTO?
 
no
everyone should do their job the best to their ability
 
in term of implementing technology and platform
 
If you're a member of a startup and it's only you who's solely focused on technology you can call yourself CTO if you want, but IMHO titles are a bit pointless in a company like that. Your problems arise when you hire someone else who is all-round more capable than you are
 
yup!
 
:( why
I mean why is that bad
 
9:28 AM
Would you want to be reporting to a boss who knows less than you do?
 
about technology? that's all I know
 
hey we do that all the time
 
OK, I'll rephrase. If you're a novice yourself and you're the CTO, you're quite likely to recruit someone who would make a better CTO than you
That person is probably not going to appreciate that arrangement
 
this "better" thing
it kind of irks me
I think there is a lot of politics to consider and sometimes this is exactly what happens
skills have a percentage in determining your position but not a complete ownership on it
 
well its should be mention in company contract that you are not going to hire experienced guy.
but that is wrong in fact
 
9:37 AM
and frankly tom I wish you could tell me I am wrong
 
Nope I don't think I can. But it's not a situation you should want to be in, imho
 
 
2 hours later…
11:22 AM
Good morning.
How would you call an enum that contains the values Any and All?
Or alternately Or and And?
I want to pass a parameter to a FindItems DAL method which receives a list of strings, and to tell it whether to return items that match all the strings, or any of the strings.
 
Condition?
 
That's a bit too vague, isn't it?
 
Might be way to generic though.
I just remember an old COM api I used some years ago, that had one like that.
To set up queries.
but yeah, it is a bit vague.
@AvnerShahar-Kashtan What have you come up with so far?
or drawn blank?
 
11:38 AM
Decided to avoid the issue for now.
Since I'm pretty sure an upcoming feature request will want the user to be able to specify which one, which will make my existing code a bit redundant, so I'll wait for that feature to arrive and keep things simple for now.
 
A wise decision. :)
 
what about scope
lol idk
 
 
2 hours later…
1:52 PM
welp
that's it :)
my code is now complicated enough for myself to lose all reasoning behind why one test finishes in 20ms while the other test takes 250ms
same code, different inputs
but maybe I should write more narrow tests instead of only testing the system as a whole
maybe some day
 
 
2 hours later…
3:34 PM
@ChristopherJ.Grace I've flat out stopped supporting Windows XP in any of my projects but I understand that 7 is still a solid OS receiving support.
 
guys a Question
how to convert date to hours?
for example
1/1/2011 = 999999999 hours
can something like that be done?
 
Hi guys, is there anyone with microservices experience here
 
3:55 PM
@HamreenAhmad Do you want hours between then and the start of Unix time?
@HamreenAhmad Something like this should do:

var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
TimeSpan ts = new DateTime(2011,1,1) - epoch;
var hoursSince = ts.Hours;
 
4:35 PM
Does anyone know how to get the correct picture size in webcamjs? I want save the file in 700x700 but it doesn't, instead it's rectangle.
https://github.com/jhuckaby/webcamjs
 
4:51 PM
@KevinMaxwell Nope, never used it.
 
@Tomwa Thanks
 
@KevinMaxwell Sorry, I dug around for a bit but didn't find anything immediately obvious.
 
@Tomwa I really appreciate your help. I know there is no information regarding this part. I feel it's all about aspect ratio and how to calculate width and height...
In the demo it uses the following:
// live preview size
width: 320,
height: 240,

// device capture size
dest_width: 640,
dest_height: 480,

// final cropped size
crop_width: 480,
crop_height: 480,
which gives 480x480 1:1 square image which is great. But when I change it to 700x700 it doesn't work and just because of the dest_width and dest_height, I need to understand why this is happening.
 
5:12 PM
Yeah I saw that:

view-source:https//pixlcore.com/demos/webcamjs/demos/crop-large.html

There's literally nothing else there though
Not sure why that wouldn't work
 
5:24 PM
exactly
 
7 is only still a solid OS because devs continue to support it because they think it's still a solid OS
extreme analogy: that's why IE6 survived for so long
even when MS did nothing to keep it alive
people continued to support it
some people need to be reminded that windows 7 is already 7 years old
and that it's time to move on
if anyone still using W7 complains that your app doesn't run on W7, tell them they had their chance to update to W10 for free and that by refusing to update they implicitly accepted not being able to run modern apps including yours :)
 
5:47 PM
Windows 10 is basically Windows 7, hardly anything has changed
Nearly every single program that exists works on 7, only the new techs i.e. DX12/UWP require 10 and those are new.
Meanwhile you have to worry about breaking your current programs by upgrading.
 
6:03 PM
Um, I've been on a long hiatus from coding for a while. Now I'm back. Can someone recommend a good book/resource to 'revise' C#?
 
@Meraj99 What do you mean "revise"?
If you've got prior experience I'd start back with simple projects and let it come back to you as you go.
 
@Tomwa Well, recall the things I've forgotten.
I'm close to 'intermediate' level as far as skills go.
 
Well, it's a bit hard to help you recall what you've forgotten when you can't remember what it is.
 
Basically recall everything really quickly?
 
I don't have any C# books on my shelf so I can't make any suggestions on that.
 
6:17 PM
Online stuff, maybe?
 
I'd honestly just relearn as you go, it's not possible to commit all of C# to memory anyways.

That's pretty much how I learned, C# wasn't my first language though.
Might be some stack overflow questions with book recommendations?
 
Well, alright, thank you....
 
Sorry, If I was more of a book person I may have had some references. Guess you could always try the O'Reilly books? I remember reading one for C++.
 
I have no idea what sort of stuff a beginner/intermediate/expert would know.
 
Would you happen to know how why MAF is ignoring my app.config file?
 
6:22 PM
I'd say.... Generics would be my tipping point.
 
Because that'd be helpful too...
I'd just get a larger comprehensive book like O'Reilly and flip to what you want to know.
 
That you still need to learn generics? or that's you're just not used to generics?
 
Should be available as a PDF as well.
He just wants a reference I think, seems he has a bit of coding amnesia and can't recall some mechanics.
 
Think about it like... very-blurrily-learnt and forgotten.
 
Oh. well then all I'd do, is watch one of derek banas videos. He covers pretty much everything up to that point for each language in a little over an hour. Here's the C# one. youtube.com/watch?v=lisiwUZJXqQ
He also has every topic in the description with a timestamp if you just want to skip to the parts you want
 
6:26 PM
Ah, that's super helpful. thanks.
 
So I have something a bit confusing.
 
is "a =+ 7;" any different to just: "a = 7;"? Is there any possible case where the output would differ?
 
I assume you mean +=?
a += 7 essentially just turns into:

a = a + 7;
 
Nope. I mean =+.
 
Hmm
 
6:34 PM
Nope
You're basically assigning positive 7.
 
And they're ints?
 
@Meraj99 There is tons of information on C# in MSDN and by searching on Google. I would start looking for what you need to know, then write down all the concepts you come across that you do not understand. Then look up those concepts. Do that in conjunction with using this chat room and working on projects with other supportive people. Contribute to an open source project. I am in a similar boat and that's what I'm doing. O'Reilly books are good to BTW :)
 
Ah, yeah don't do that
 
I saw =- just assigns the value to negative of the value. But I saw =+ being used instead of just =. Was wondering if it would ever matter?
 
It should be a = +7
 
6:35 PM
All that is likely to do is confuse people
it looks like +=, but isn't
 
WHY you'd ever write it that way
 
@ChristopherJ.Grace Alright, thanks :D
 
is beyond me
 
It's just confusing me because I have no idea why they'd do that...
 
ditto with a=-7
where you actually need the minus in there
I'd write it a = (-7);
 
6:37 PM
But here's the question: int a = -7; int b = +a. What'd be b? -7 or +7?
 
Speaking of looking for help understanding C#...
 
b is -7 still
 
meh
 
My initial thought would be that it'd get the absolute value. But then i realised that'\d make the absolute value function pointless.
 
6:38 PM
How does this: Enumerable.GroupJoin<TOuter, TInner, TKey, TResult> Method (IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey‌​>, Func<TOuter, IEnumerable<TInner>, TResult>)
Wind up looking like this in code var newDiscards = currentTreadDiscards.GroupJoin(
previousTreadDiscards,
ctd => ctd,
ptd => ptd,
(ctd, g) => g.Select(c => new { CurrentTreadDiscard = ctd, PreviousTreadDiscard = c })
.DefaultIfEmpty(new { CurrentTreadDiscard = ctd, PreviousTreadDiscard = Guid.Empty }))
.SelectMany(g => g)
.Where(g => g.PreviousTreadDiscard == null).ToList();
I mean, the documentation start with "Enumerable.GroupJoin<TOuter, TInner, TKey, TResult>" Doesn't that mean there should be a declaration in code something like List<string> s = new List<string>?
 
Oy
 
The Documentation continues with "Method (IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey‌​>, Func<TOuter, IEnumerable<TInner>, TResult>)"
 
I'm going to be honest, I have no idea what your question is.
 
It looks like the kind of documentation I'd give a skip.
@Tomwa Same XD
 
@betarunex Lol
 
6:46 PM
Looks like they called the function by using lambdas?
I just don't know what the question is lol.
currentTreadDiscards.GroupJoin(
previousTreadDiscards,
ctd => ctd,
ptd => ptd,
(ctd, g) => g.Select(c => new { CurrentTreadDiscard = ctd, PreviousTreadDiscard = c })

This is the GroupJoin call
Everything afterwards is Linq
 
Well, in working with Linq, I often refer to the documentation to figure out how to use the functions. But the documentation is cryptic.
 
What are you trying to accomplish?
 
So according to the docs, previousTreadDiscards must be an IEnumerable<TOuter>?
 
Yes
 
The problem at hand is I want to finde all the currentTreadDiscards that do not have a matching previousTreadDiscard, but it would also be extremely valuable to know how to read the documentation.
 
6:50 PM
It must be an IEnumerable (i.e. a List or something implementing the IEnumerable interface) containing things of type TOuter
I can explain it piece by piece.
Enumerable.GroupJoin
The first thing is the type
 
What is a TOuter? There doesn't appear to be any type by that name.
 
Any Enumerable i.e. a list, etc.
has GroupJoin as a method
List<p> pStuff = new List<p>();
pStuff.GroupJoin(...);
TOuter and TInner are types
They're generics
One Enumberable is "Outer" and the other enumerable is "Inner"
In the pstuff example, TOuter would be p
Method (IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey‌​>, Func<TOuter, IEnumerable<TInner>, TResult>)
Everything in <> before "Method" are generic types, they're not necessary because the language can infer them most of the time.
Everything after Method are parameters.
So it expects an IEnumerable of TOuter things, an IEnumerable of Tinner things, and then three functions.
Based on your function call:
currentTreadDiscards.GroupJoin(
previousTreadDiscards,
ctd => ctd,
ptd => ptd,
(ctd, g) => g.Select(c => new { CurrentTreadDiscard = ctd, PreviousTreadDiscard = c })
.DefaultIfEmpty(new { CurrentTreadDiscard = ctd, PreviousTreadDiscard = Guid.Empty }))
.SelectMany(g => g)
.Where(g => g.PreviousTreadDiscard == null).ToList();
currentTreadDiscards must be an IEnumerable (i.e. A list)
currentThreadDiscards is IEnumerable<TOuter> from the documentation.
I'll just write some sample code.
I'll paste it to gist, 1 sec.
 
I cannot find anything defining TOuter. Maybe it is just a convention for naming whatever type is plugged in there.
 
TOuter is infered
It's not necessary to pass in because it IS the outside list
that's what the "this" in the docs means
the first thing passed in is the inner list
 
7:05 PM
Oh here it is "Type Parameters
TOuter
The type of the elements of the first sequence.
TInner
The type of the elements of the second sequence.
TKey
The type of the keys returned by the key selector functions.
TResult
The type of the result elements."
 
@ChristopherJ.Grace TOuter is called a 'generic type parameter'
It's a placeholder for any type you choose (subject to some constraints)
 
I see. TOuter is simply the name of the parameter, like hours in a DateTime function.
 
Not exactly
it denotes a type, not an instance. An argument to a method is an instance
But in the most simplistic sense yes
In the case of generic methods like GroupJoin, the compiler infers the generic type parameters from the method's usage. Strictly speaking if you're for example GroupJoining two sequences of integers, for example, what you're really calling is GroupJoin<int, int, int, SomeResultType>
The compiler lets you omit the angle-brackets because it can decide what they should be from what you pass as arguments
The other case where generics shows up a lot is collections, for example List<T>
With collections you usually have to specify the type parameters, e.g. var list = new List<int>();
 
That makes sense. I guess the description of how to call it via method syntax vs query syntax is left to this help topic: msdn.microsoft.com/en-us/library/bb397947.aspx
Awesome guys thanks! You have no idea how many times I've stared at the documentation trying to figure that out.
What is gist?
 
7:27 PM
internet code notepad, basically
 
@ChristopherJ.Grace See if that helps
Note: We didn't pass IEnumerable<TOuter> because we called it as a method of an IEnumable i.e. outer.GroupJoin() instead of Enumerable.GroupJoin()
        Enumerable.GroupJoin(
            outer,
            inner,
            o => o, // We're selecting elements from the outer list in this case we just select them all
            i => i, // We're selecting elements from the inner list in this case we just select them all
            (o, g) => g.Select(c => new { Item1 = o, Item2 = c }) // This is our result function, it returns a tuple of each element if each element has an equal value
            .DefaultIfEmpty(new { Item1 = o, Item2 = 0 }))  // This speficies a default value for the tuple if the row doesn't match.
In this case GroupJoin is considered an Extension Method
@ChristopherJ.Grace That about sums it all up I think
@TomW Did I miss anything?
 
7:46 PM
@Tomwa g is used in the Lambda to stand for group?
 
g is just an arbitrary name, it's the result IEnumerable.
 
I've seen that chosen in other examples as well.
 
It's a commonly used name, but it isn't mandatory.
        Enumerable.GroupJoin(
            outer,
            inner,
            o => o, // We're selecting elements from the outer list in this case we just select them all
            i => i, // We're selecting elements from the inner list in this case we just select them all
            (o, pizza) => pizza.Select(c => new { Item1 = o, Item2 = c }) // This is our result function, it returns a tuple of each element if each element has an equal value
            .DefaultIfEmpty(new { Item1 = o, Item2 = 0 }))  // This speficies a default value for the tuple if the row doesn't match.
Works just as well
It's just a parameter in an anonymous function
Same for o, i, and c of course.
 
The result is grouped by the inner and outer selectors.
 
Yes.
o => o, is the outer selector
i => i is the inner selector
 
7:51 PM
Yo yo yo
 
in this case we just lined up every element and joined if they were the same.
@VermillionAzure Howdy howdy.
 
What are you, German?
/s
 
Guten Tag!
@ChristopherJ.Grace

You can use more advanced types and selectors as well.

https://gist.github.com/anonymous/9b6e2916172484d6011a77b2af8c58e5
I need someone knowledgeable about C# to help me out with DLLs, specifically loading DLLs and probing.
 
8:17 PM
Never mind I fixed it.
So empty in here.
 
8:31 PM
@Tomwa I'm back for a bit before switching to football mode. It's amazing how deep dependencies go when looking at dlls through dependency walker.
 
I'm so sick of managing dependencies
Did my earlier examples help at all btw?
I'm bad at explaining things without code :/
I love this game, I really do, but holy shit this guy writes fucking terribly structured programs.
 
probing?
 
everyone does
 
Everything is spaghetti code, I'm going to need to hook every goddamn method.
You'd think the code for changing seasons would be in one place...
NOPE
There's about 11 functions you have to call manually to make such things complete fully
 
9:11 PM
Updating a const in a compiled assembly? Not easy.

Literally have to find everywhere the value is used and update it.
 
9:40 PM
Why would Desktop Window Manager (dwm.exe) consume 15 FUCKING GIGABYTES on windows 10?
 
 
1 hour later…
11:07 PM
God it's been so long since I used Mono.Cecil
 

« first day (2185 days earlier)      last day (2757 days later) »