« first day (820 days earlier)      last day (4136 days later) » 

2:12 PM
I'm doing a Linq query to populate the parameters of a constructor. The constructor takes 10 arguments. How do I form the query into arguments? This is what I have:
        public Student GetStudentsByUserName(string userName)
        {
            abDataDataContext db = new abDataDataContext();
            AdventureBrainUser abu = new AdventureBrainUser();
            var getStudent =
                (from n in db.AdventureBrainUsers
                where n.UserName == userName
                select new Student
                {
                    pkid = n.PKID,
                    userName = n.UserName,
                    firstName = n.FirstName,
                    lastName = n.LastName,
'Student' does not contain a constructor that takes 0 arguments
@Eve or anyone
 
Eve
Don't use the object initializer, use the constructor.
new Student
(
...
)
But a constructor taking ten arguments is... Eh.
 
how do I pass the values into it? I tried that at first. I tried getStudent.property
but the properties don't show up in intellisense
 
can you make an overload that takes a usersettings object or something?
the n thing
 
Eve
Assuming that the properties in the object initializer that you show us are in order of the constructor's parameters: new Student(n.PKID, n.UserName, ...)
 
outside the Linq, n isn't available
All I can access is getStudent
If I do the overload, I still have to pull out the values. I don't know how. I'm not savvy with collections or linq.
 
2:30 PM
ok, what if you have a constructor with no arguments and use it as you do now?
or like Eve suggests
if you don't new up students everywhere maybe it is not a problem to have ten parameters in the ctor?
 
Eve's method didn't work. I get "Error 3 Cannot implicitly convert type 'System.Linq.IQueryable<adventurebrain.Models.Student>' to 'adventurebrain.Models.Student'."
 
that is a different error
 
yes, it is. It's different code.
 
you try to return a list of students but the method signature is returning a single studene
you might want Single or First
 
and I want a single student.
 
Eve
2:36 PM
Can you show us what your code looks like now?
 
abDataDataContext db = new abDataDataContext();
            AdventureBrainUser abu = new AdventureBrainUser();
            Student getStudent =
                (from n in db.AdventureBrainUsers
                where n.UserName == userName
                select new Student(
                    n.PKID,
                    n.UserName,
                    n.FirstName,
                    n.LastName,
                    n.Email,
                    n.IsLockedOut,
                    n.CreatedDate,
                    n.LastLoginDate,
 
I never use the sql syntax but you want to replace where with single I think
 
Eve
And the error is on line...?
 
select is underlined
my only error
 
Eve
First, add a ) after the constructor, you're not closing it.
 
2:38 PM
Your method signature is not in agreement I think:
public Student GetStudentsByUserName(string userName)
{
 
Yeah I fixed that already
 
Eve
Then, after you close the bracket, add a .Single() after it.
What's the purpose of abu anyway?
 
.Single<>?
oh. I can delete abu. I thought you needed it to access the table at first.
 
Eve
I don't think that it'd be necessary to specify type arguments explicitly, but if you really have to, put Student between <>.
Never used LINQ to SQL.
 
Error 3 Cannot convert method group 'Single' to non-delegate type 'adventurebrain.Models.Student'. Did you intend to invoke the method?
 
Eve
2:41 PM
2 mins ago, by Eve
Then, after you close the bracket, add a .Single() after it.
 
.Single<Student> is the error. The other one is gone
 
Eve
Read my message again, then.
 
SignleOrDefault migt be an option depending on what you want, Single will throw on no match, SingleOrDefault will return null. Both will throw on 2 or more matches
 
That wasn't available. That's why I asked .Single<>?
 
Eve
You have to put () after it.
 
2:43 PM
OK.It did work. I assumed it would show up on intellisense.
My bad
 
Eve
No worries.
The above is also why I use var if I can.
I would have declared getStudent as var and then returned getStudent.Single(). That way there would've been no need for brackets around the LINQ query.
 
var is like a generic type, right?
 
Eve
No, it's just implicitly typed.
 
@RyanJMcGowan var is letting the compiler figure out the type, t is the same thing but reads shorter
 
like var in javascript
 
Eve
2:48 PM
Type inference is very powerful and I wish that C# offered more alternatives to shorten your code.
I like F# because it's pretty much all based on type inference.
 
OK, now when I do a getStudent overload with the PKID, it's not wanting to see a GUID as an object.
Actually it doesn't like "=="
How do you cast a Guid to an object?
 
Eve
I don't know what you're talking about, but you can just use the cast operator.
You know what kinda worries me? That questions like this:
0
Q: check if is number digit

user1942298i want to check if user is input a number or not if yes i want the func to keep running else i want to alert him and run it agin. { Console.WriteLine(String.Concat("choose your action" ,Environment.NewLine , "1.Deposit" ,Environment.N...

Are usually about withdrawing, depositing, transactions or stuff like that.
I wouldn't feel too safe if those applications would end up being used in bank systems.
 
I should probably go to bed. - _-
that moment when the sun comes up and you're still not ready to sleep.
 
3:51 PM
I have a class called Product which has a navigational property called ParentGroup(of type ProductGroup). ProductGroup has a property called GroupName. I am using automapper and I have created a viewmodel class named ProductVM. It now contains a property named ProductGroupGroupName. Now how do I configure automapper so that ProductGroupName would work?
I want the property to be named ProductGroupName. Not ProductGroupGroupName
 
 
1 hour later…
5:17 PM
 
Eve
Hehe, I remember a UML teacher using that picture as an introduction to his talk.
I would've added a "How it was tested" panel, with people sitting on the tree rather than on the swing.
 
5:35 PM
lol
are you a student Eve?
 
Eve
Yes.
Trying to get a degree in computer engineering.
 
How many years in total and how many left?
 
Eve
5, 2.5.
Should get a bachelor this summer, then hopefully move out and go study in MA.
 
Harvard?
 
Eve
No idea, depends on what my current university offers. I'm not ambitious though, I just want to get some paper and get to work from home.
 
5:56 PM
I studied five years but none of it was programming.
 
Eve
May I ask what, then? Genuinely curious.
 
Mechanical engineering, idk if it is the correct translation 'maskiningenjör' in Swedish
I think I'm pretty much done drawing CAD as it feels now though
 
Eve
I guess so. I don't like the whole mechanical part of what I study, I'm more software oriented, but I guess I have to deal with it.
 
6:45 PM
.
@canon Nice video!
 
@CCInc hah, thanks. the extension page looked really empty without something
 
Yea, I noticed :)
 
@CCInc You haven't fed me any btc yet.
Less chatting, more crypto crunching!
I want you to get a pen and paper and start trying to solve blocks by hand. GOGOGO
 
Oh yea! sorry
:P
 
Is it unreasonable to expect that every comic book store clerk would have a smart phone?
 
6:55 PM
Sorry, my .02 out of .1 is still pending...
Once it gets done I'll feed some coins
 
That was quick.
 
What program are you using for mining?
 
GUIMiner
 
does it need some sort of account?
 
Yes
It needs a Slush Pool account
I think that's it, Billdr knows more than me
 
7:05 PM
@Billdr you have a link to a nice tutorial for that?
 
The tutorials were all bad
 
eeeeeh
 
Do you have an AMD GPU or nVidia?
 
Yea, getting into mining is a nightmare.
It really is not the way to go.
 
What's the other way(s)?
 
7:06 PM
nVidia
 
Is it fairly powerful?
 
@Billdr but why do you want CC to do it?
 
@JohanLarsson I'm cheap
 
^
 
@CCInc don't know gaming card gtx 680, have semi high end CAD card at work
 
7:08 PM
A normal person should either buy btc or sell something for it.
mining is slow, expensive, and complicated.
 
OK @JohanLarsson you can use the CUDA miner option in GUIMiner
^^
I'm not paying for energy, so I'm golden
 
@CCInc does it slow down the computer much?
 
No, if you don't really use your GPU everyday
 
I could try running it while drawing cad :)
 
ha
that seems like a bad idea.
 
7:11 PM
yeah
 
WTF?! I can put MILK in my TEA?
 
too painful signing up for something no mining for me
 
Eve
@JohanLarsson Coincidentally, I was watching that guy's videos just now.
 
it is my kind of humor, watched it twice
 
Eve
7:18 PM
Then just watch all the other ones alltogether. It shouldn't take more than an hour.
 
hey
 
hey
 
anyone here familiar with java? .-.
 
belch I think some people are
 
Eve
 
7:25 PM
@Crowz What's up?
 
Eve
Best steak I ever managed to make.
 
Java questions, I can read them. Sometimes I even know how to answer them. Sometimes.
yum
 
Does anyone know about the chat API for bots and such?
 
@CCInc I thought there was no api
 
Eve
I thought you made HangBot?
 
7:27 PM
Well, there isn't and I did
 
I need to find out when a user enters a room
 
Eve
Is the data encrypted?
 
... like?
 
Eve
How does the protocol look like? Size, id, content? Is content encrypted somehow?
 
7:30 PM
That's what I don't know
 
@JohanLarsson My wife didn't get it.
 
Eve
You built the bot and you don't know the underlying protocol...?
 
@CC sniff the packets and see?
 
@Billdr that probably means she is a good citizen
 
@Eve yes, I have built a bot also without knowing the underlying protocol
 
7:31 PM
@Eve Let me check again then...
 
Eve
@StuartBlackler How, exactly?
 
Ah
Perhaps I could detect when a user enters by checking the users array for changes
 
Hey @acidzombie24
 
user34537
Hello
 
Hey it's @acidzombie24
 
7:32 PM
@Eve for me, intercepting events doing something and then re-triggering the event. Don't think that these are bots that are advanced. They are rather simple if im honest
 
Hey it's @DavidHall
 
@JohanLarsson It's like every programming tutorial I've ever read.
My cheeks hurt.
 
user34537
Hey it's @CCInc. Why are you saying hey?
 
because you have like... lots of reps
 
user34537
@DavidHall: I guess I'm just wondering what the problem is with unit testing bc I never felt a need for DI ;P
 
Eve
7:33 PM
@StuartBlackler Well, I don't honestly even know what technology this chat is written into, but I assumed there was a dedicated protocol for it -- Just like IRC.
 
user34537
@CCInc: Oh, i have no answers tho evil vicious grin
 
@Eve I dont think so, ill see if i can find a couple links two secs
 
@acidzombie24 are you saying you do unit testing without DI, or that you don't do either and find no need for either?
 
Eve
Oh, it's not necessary. I assumed that by bots you were talking about programs which managed everything, including the connection to the chat, parsed incoming/outgoing packets, etc.
 
@Eve this is the main one used by alot of people: github.com/Zirak/SO-ChatBot But all the commands are echo'd to everyone effectively and I didn't like that, so I created this one: github.com/sblackler/stackbot
 
7:35 PM
@acidzombie24 for example - Konrad Rudolph says he does unit testing without DI but I've always found a point where DI makes things very much easier
 
Eve
Ah, I see.
 
user34537
I don't do unit testing for my own C# code and my work doesn't on the project I am doing (they are cleaning up atm so no point until its stable)
 
user34537
but in my C++ code I do some unit testing. When I build from the command line it runs my unit test and it takes ~1sec for it to run and I see red text on the console. Its very primitive but it works
 
@Eve Basically, all our bots detect when a message is sent and Stuart's detects when text is entered in the textbox
 
user34537
My classes always only do one thing, the thing it is meant to do and I just never had a problem testing it. Nothing is mashed into a place it isn't suppose to be. Can you explain an example of what test is more simple with DI?
 
7:38 PM
Cool - so how do you handle dependencies? Whether they be external infrastructure, such as database, filesystem etc.
 
Eve
@CCInc ok
 
or whether it be dependant logic that you just want to ignore for now.
 
user34537
hmm. I'll take a database. I use dapper. Lets say its stackoverflow. I'd just have a function somewhere with the sig IEnumerable<Answers> GetAnswers(long QuestionID)
 
If I'm testing (or indeed even simply running in isolation to see what it does) a piece of code (usually a method) I want to be able to ignore all those dependencies
so how do you replace the reference to the actual stackoverflow (for this example) api?
 
user34537
In my unit test i'd insert a dummy question, get back its id. insert dummy questions to that id. Then use the function to see if the expected amount matches, do deletes, etc and thats how i'd test it. reads your msg
 
7:41 PM
Do how are you pointing your method under test at your test instance of the database and not at production?
*"so", not "do" in the above
 
user34537
I don't ignore the API. All my code is using a dev server. My unit test can delete the question automatically. Its... not a problem, why ignore?
 
(and sorry if I sounds like I'm grilling you :) it's just how I ask honest questions)
so your unit test is executing both the code to update the database and the code to then clean it up?
(which is all fine - I actually think databases are a bad example - they are very easy to replace with in memory version to test against :) )
 
user34537
Yes but since its dev it doesnt mean I NEED to clean it up. If i were to look at the front page i dont want to see a bajillion unit test questions so I do clean it up
 
but in your unit test you ideally don't want to have any code except for the code to test one thing
 
user34537
for sql querys that delete rows i like write begin, update, select and rollback. So.. if i dont update correctly I can see and not need to correct the data.
 
7:44 PM
as soon as you are executing the code to delete you are doing two things
 
Hi all
 
OMG
OMG OMG OMG OMG
OOOOOOOMMMMMMMMMMGGGGGGGGG
It's JAB!
 
user34537
Well I consider it a family. I should be able to test insert/update/delete in the same family of unit test. Also FYI I only test public methods as testing private methods is... just strange cause outside code doesnt use it and usually it depends on other privates
 
@Billdr Oh I am having some problems with my GUI, I am trying to OpenGL to fix it
 
yeah, totally with you there as far as private methods
 
7:46 PM
@CCInc and notice my rep
 
user34537
Can you think of any good nondb unit test?
 
@Crowz That one's out of my league. I did some android stuff, nothing OpenGL.
 
sure - lots, I write them every day :)
 
@CCInc Im gaining on you! :)
 
7:47 PM
:O he is catching up! Only .4K more rep!
 
or rather - I like to be able to test everything
but only that one thing
 
@CCInc Thats today!
 
If I have a method that calls a couple of other classes to gather necessary information, I want to have the option of being able to totally ignore those classes while focusing on just that method
And that is where I find DI really helps
take the very simple example of a method that has an if statement where the condition is a boolean method from another class
 
@JABFreeware Haha good luck! I'll race you to 2K!
 
very often that other class with the other method can require a bit of work to get up and running.
so being able to just inject in a stub of the dependency is great for m,e
 
7:50 PM
@Billdr oh it's probably fixable in java alone, but I feel like OpenGL will work
 
user34537
@DavidHall: Why does it need to go through a 'couple of other classes'
 
it lets me run the code I want to run, and ignore the rest
are you saying you never call off to other services to work things out?
so you have your classic bad example User class
which has a boolean approved for credit method
my class that processes payments needs to check this method (or probably better factored as a service - which is why these sort of top of the head examples are so hard to give :) )
but you see the point I hope - the logic for calculating credit approval does not belong in the payment process class. But the payment process class needs to know about it
The real world example I have is I've been tasked with migrating a big VB.Net Asp.Net site to Azure
and along the way they've decided they need c# too
for me the best way to understand the code I'm working on is to actually run each method in isolation
 
user34537
I'm not exactly sure but i'd probably just hardcode known userids and check if its true/false or do what i did before and create it on the fly as a unit test family (it doesnt mean they depend on eachother but may use eachother)
 
user34537
oh
 
and currently with the architecture I find that really really hard to do, since I need the whole application stack
 
user34537
7:54 PM
Can you give an example where you might unit test SO and need DI?
 
if the application had been build di, I could inject just enough to make each method run, and be happy that I understood it properly
 
user34537
But lots of methods require other methods...
 
Why does it keep saying each post is to me "*1"
?
 
user34537
I'm not exactly sure how you can test if delete actually works unless you use insert or whatever
 
yes, lots of methods do require other methods
which is why di is so powerful
well, yes, exactly
that is why databases are a bad example :)
 
user34537
7:56 PM
ok so... give me a DI unit test example for stackoverflow :p
 
I've almost given up on using unit tests for testing database logic
 
user34537
like if we built it
 
integration tests are better for that
but for the methods that use the resulting output of a database call, then unit testing those is great
 
@JABFreeware What you mean?
 
Does anyone know where the best place to ask about using the stackexchange data/site dump for my dissertation? Maybe @Kyle @Johan or @Pheonixblade9 will know? :)
 
7:57 PM
@CCInc nvm
 
user34537
hmm it sounds like I mix unit and integration together. doesnt care
 
well, it is your choice to care or not :) free world
 
@StuartBlackler no clue, don't understand the question tbh
 
all I can say is I find DI very useful, every day
the example I've given with the migration I'm doing onto Azure is really the best I can think of.
 

« first day (820 days earlier)      last day (4136 days later) »