« first day (1725 days earlier)      last day (3222 days later) » 

10:00 PM
ahh
 
@SteveG I've got a question. If I have a List<Model> and I have two generated list of List<Model> how can I add both of those list to List<Model>?
 
addrange maybe
 
If it is really List<List<Model>>
you may need a select many (or two) first
 
Basically I have something in list e and f and need the responses to contain both.
                List<ResponseModel> responses = new List<ResponseModel>();
                if (e.Any())
                    responses = e;

                if (f.Any())
                    responses = f;
but if something exist from the parse where both are filled, I need both e and f
As an example.
Or am I doing something that I shouldn't be?
 
I would start with an IEnumerable (instead of List) and just Concat both if necessary
call ToList afterwards if desired
so:
 
10:11 PM
I only have List, is there a working around?
 
IEnumerable<ResponseModel> responses = new IEnumerable<ResponseModel>();
                if (e.Any())
                    responses.Concat(e);

                if (f.Any())
                    responses.Concat(f);
return responses.ToList();
See code ^^
 
I see.
I get the squiggly for that, I've yet to use IEnumerable is there anything fancy I need to do for the interface implementation>?
 
IEnumerable is in System.Collections.Generic
you'll need System.Linq for Concat
 
Which I have. But I get:
Cannot create abstract instance of Class or Interface
And that is on the new declaration.
 
whats the diff between concat and addrange? is one better?
 
10:15 PM
@SteveG Not sure, good question though.
@BradleyDotNET Why can't I use Concat that is built into List?
 
@BradleyDotNET It's inadvisable to enumerate an ienumerable multiple times like that.
(the e.Any(), where e is then enumerated later with ToList)
 
oh, sorry, no new IEnumerable
 
Enumerable.Empty<ResponseModel>()
 
e.Any will enumerate one item
 
So, now I'm confused.
 
10:19 PM
though granted, Concating an empty collection will do nothing
 
@BradleyDotNET but depending on how the source IEnumerable is emplemented can cause performance or logic problems
If I was doing the concat approach I'd just unconditionally concat
 
?
 
And the Concat that is "built-in" to List appears to actually be the IEnumerable version anyways
@MikeAsdf sure, its unecessary here
 
If I wanted a list in the end I'd probably use AddRange
 
I receive a null reference when I don't do the equal.
 
10:20 PM
Right... just set it to a new list
Sorry for the confusion
 
What do you mean?
 
IEnumerable<X> = new List<X>
 
If I have an IEnumerable that's actually the Concat-group of multiple lists, I'm not sure if ToList is smart enough to estimate a count
 
Or just store it as List
Its smart enough
 
@BradleyDotNET you can't create an instance of IEnumerable ;)
 
10:21 PM
yeah, off a bit in my head code today
 
I'm so confused, so what?
 
THAT'S RIGHT, I AM THE GREATEST PROGRAMMER IN THE WORLD
 
The diference between AddRange and Concat here is going to be lazy execution/enumeration
 
If you do ToList or AddRange and the source is actually an ICollection(<>), then the count will be used for intelligent list allocation
 
So how can I fix?
 
10:22 PM
IEnumerable<ResponseModel> responses = new List<ResponseModel>();
                    responses.Concat(e);
                    responses.Concat(f);
return responses.ToList();
final code ^^
 
wat
 
or use AddRange if you want to enumerate the source collection right away
 
responses.Concat does nothing
 
what do you mean it does nothing?
 
I want the values of e and f to be added to a list. As e and f parse xml since the root xml has deviations which is why I push e and f to a list.
 
10:24 PM
@BradleyDotNET string x = "hello world"; x.Replace("hello", "hell"); Console.WriteLine(x); //prints "hello world"
 
Maybe this will help:
                var e = submission.Sections.Where(obj => obj.Screens.Screen.Responses.Response == null && obj.Screens.Screen.Responses.Responses != null)
                    .SelectMany(obj => obj.Screens.Screen.Responses.Responses.Response.Select(response => new ResponseModel { Label = response.Label, Value = response.Value, Type = response.Type })).ToList();

                var f = submission.Sections.Where(obj => obj.Screens.Screen.Responses.Response != null)
                    .SelectMany(obj => obj.Screens.Screen.Responses.Response.Select(response => new ResponseModel { Label = respo
 
in other words: you need to assign the result of Concat or Replace to something.
 
So sometimes the xml will fall into e other times it will be f.
But sometimes it will be both.
Because this third party xml sucks.
 
List<ResponseModel> responses = new List<ResponseModel>();
responses.AddRange(e);
responses.AddRange(f);
?
 
oh, sorry
yes, forgot the assignment
IEnumerable<ResponseModel> responses = new List<ResponseModel>();
                    responses = responses.Concat(e);
                    responses = responses.Concat(f);
return responses.ToList();
 
10:30 PM
So what would be better vs what @TravisJ suggested then?
 
Almost identical
one just enumerates at a different time than the other
 
No point in downcasting just to call tolist again imo
 
My task just switched from "Allow us to to change these contracted settings" to "Allow us to change any setting with this attribute on it". Ugh....
 
you can chain in that instance as well..
return responses.Concat(e).Concat(f).ToList();
 
I just had the ToList because he said he needed a list
I wouldn't put it in list form unless you really needed to
 
10:32 PM
Does one have any performance boost over the other?
 
Right, but it was already a list which was why I figured addrange would be more appropriate
 
assuming you want to take advantage of lazy enumeration of course
 
I sadly need to.
 
then AddRange is fine
Lazy enumeration will buy you nothing here
 
The second round of enumeration will cause a very slight performance impact of nano seconds if it is in memory already and the set is small
 
10:33 PM
the only difference at that point is really readability
 
Yup
 
AddRange seems fine to me
 
It seems strange that there is a new list going on though as well
why not just use
return e.Concat(f).ToList();
and not even deal with instantiating a list
Unless there was more to the shown snippet that we are missing
assuming that e and f can't be null
 
There is, I just didn't include that.
 
ok
 
10:35 PM
@TravisJ Well, e and f can be null based on the Xml.
 
ah, if you use e.Any() and e is null you will get an exception I believe
 
@TravisJ You don't, it grabs the first one if it can.
 
if e is null it will throw
if e is empty then it won't
 
It should never be null but empty, let me rephrase.
 
I think you probably got the point of the discussion though, we are just talking about nuance at this point I believe.
 
10:38 PM
Yeah, I appreciate it. I'm still pretty uncomfortable with IEnumerable.
 
What if the group was so massive it crashes your query though?!
Heh, just kidding, but I actually have a corner case that does that to me sometimes. I am working on resolving it at the moment.
Check this fun message out:
The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
 
@TravisJ lol, when the error message is like "shit, dude. call tech support" that's pretty bad
 
lol
 
Yeah, I don't think I'd have that problem.
That is crazy though.
 
It happens because I am sending too many primary keys and it overflows the query length limit I think. Shouldn't be too hard to fix.
Need to filter up front more.
 
10:42 PM
I haven't encountered, so my remarks would more than likely be unhelpful.
 
Or maybe it should just return a message.
catch( SqlException sqlError )
{
    TempData["ErrorMessage"] = "Why did you search for *everything* like that?! WTF. Here, this is what you did. This is what you caused: " + sqlError.Message;
    return View();
}
 
IEnumerable can be very useful. One time I used it to grab the first 200 file records out of 100000 so we could batch process
Froze up the machines before trying to pull up the whole list, batching made our resource usage return to nominal
impossible to do without lazy enumeration though
 
possible, just inefficient
SQL paging is very inefficient. It still enumerates up to the point you want, then makes the query
 
10:58 PM
@TravisJ hahaha
 
:D
@BradleyDotNET - I think that question has a lot of rant qualities. It could have [citation needed] all over the place.
 
true that
 
Not going to get into specifics there though, it is a lost cause :P
 
still not really a rant imo though
Definitely could use citations
 
Well, there is a lot of places where he says "fact is" with not backup, any time someone starts using "facts" that they have inferred based on basically emotion it starts to feel like a rant. It feels like someone with an emotional reaction made up facts to support their mood.
"the fact that the correlation between reputation and, well, anything, was poorer than expected" [citation]
"People with huge reputation (and many older good answers) can keep earning reputation faster than those who are actively involved in the community" [citation]
"the fact that they were relatively good at answering questions or moderating 5 years ago" [citation]
"I'd like the people moderating my questions to represent the best of the best that SO has to offer now, not the best from 5 years ago." [citation]
like all of those^
 
11:05 PM
is there a way to know who is the last person make changes in stored procedure?
 
Probably not unless you had some sort of version control for it?
 
hmmm, found this script online: SELECT SPECIFIC_SCHEMA + '.' + SPECIFIC_NAME AS ProcName, LAST_ALTERED
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
AND LAST_ALTERED > GETDATE() - 7
but it does not have option to query the username
:/
 
People also use the word "fact" too much :)
so I'll give him a pass for inappropriate but common usage
 
the fact is, fuck you
 
who said it?
 
11:12 PM
-Michael Scott
 
who is he?
 
-Abraham Lincoln
 
he is Patrick
 
!!youtube no this is patrick
 
11:15 PM
do any of you guys use Coverity?
 
no, I kinda wanna go bother the guys in Seattle for a job though :P
 
Is Steam down?
 
@Pheonixblade9: i am looking to change job to move to seattle too
 
@JackyNguyen it's nice here. Expensive.
 
I am in Olympia, 1h by driving down :D
 
11:21 PM
@KendallFrey yes
 
ha 14 stars for dropping VB, forgot about that one :)
they would probably just be troll closed
 
Is it possible to have the same file open in two tabs in vs?
 
Should be
I can't recall having the same file open twice in the same mode, but I've had the same file open in different modes
 
Yeah different modes should be easy
I can't seem to get them to open right next to each other though
 
what happens?
 
11:27 PM
@TravisJ: double click on the file => open 1, single click on the file => open 2nd
 
@JackyNguyen - It just seems to navigate to the open one when I single click
Oh well, it isn't a big deal
I will just place it all in a new file and go back and forth then delete the temp file
 
make sure you drag 1 one the tab out of vs first
 
Getting complicated :P
 
ok, double click the file, it will open 1 tab, drag that tab out of vs
single click on the file, you have another tab
nvm, i lied
lol
 

« first day (1725 days earlier)      last day (3222 days later) »