« first day (2855 days earlier)      last day (2319 days later) » 

10:00
3 mins ago, by Xariez
My best attempt so far is ViewModel.Events.OrderBy(x => new { x.LastName, x.FirstName}); but that doesn't do shit
your IDE should tell you it doesnt do shit
System.InvalidOperationException: You msut call UpdateNonNotifyingList() after updatnig a list that dose not implement INotifyCollectionChanged() if i try that @Wietlol
mr5
mr5
it's immutable(or was it non mutable) ffs
jesus fuck them typos, just realised
mr5
mr5
what the hell is that error
10:01
mr5
mr5
I never encountered that UpdateNonNotifyingList
If I don't use ChangeTracking in EF. How would I update a subentity? e.g: Company has Users. I want to add a User to Company.Users. Is there any other way than directly accessing dbContext.CompanyUsers?
mr5
mr5
@ErwinOkken show us your query
also, your database credentials
also, your credit card info
just to be safe
anyhow
mr5
mr5
use binding and all your problem will be gone.
10:03
(no Rebecca Black)
I am, for the initial data. But for some reason nothing happens if i update the initial data after it has loaded @mr5
I primisi
mr5
mr5
I see rebecca black there
don't go there guys
damnit @mr5 i almost had them
<ListView ItemsSource="{Binding Events}"> ... </ListView>
public ObservableCollection<Event> Events { get; set; }
mr5
mr5
10:05
@Xariez try updating the data on ViewModel.Init()
not on ctor
But
I can't
mr5
mr5
but that should work as well
The data updates when a user hits a toggle button
I can't just update it whenever
mr5
mr5
update on event then?
User hits a button, command is called, list gets resorted
mr5
mr5
10:06
that should work
View doesn't change
mr5
mr5
maybe you're binding in the wrong context
check if it's even get hit
It does
I'm pretty sure i'd notice if i'm binding into the wrong context
mr5
mr5
Events = Events.OrderBy(e => new { e.Party }).ToObservableCollection()
Is ToObservableCollection() even a thing?
mr5
mr5
10:08
nah, try making an extension
assigning IEnumerable on OE won't compile afaik
var company = this.dbSet.FirstOrDefault(u => u.Id == entity.CompanyId);
                if (company != null)
                {
                    company.CompanyBranche.Add(entity);
                    this.SaveChanges();
                    return entity;
                }
                return null;
mr5
mr5
where's the db credentials
and the credit card info
nah jk :)
But that won't work without ChangeTracking, since SaveChanges will not see company.CompanyBranche being changed
Wouldn't that give us the same result as ViewModel.Events = new ObservableCollection<Event>(ViewModel.Events.OrderBy(...)); though? @mr5
And at that point I do not have direct access to the dbSet of CompanyBranche. So I'm wondering if it's possible at all.
mr5
mr5
10:09
@ErwinOkken you should be using dbSet.Find here though
Because doing that throws an exception
@mr5 I want to explicitely search the database, and not the local cache.
But that's irrelevant for now :p
mr5
mr5
@Xariez yes. it's the same on our implementation of ToObservableCollection()
So that would still just throw then. Hmm.
@mr5 why Find?
mr5
mr5
10:11
@Xariez what's the message?
@Wietlol caching ^^
1s, Let me check
Find includes caching?
`Unhandled Exception:

System.InvalidOperationException: Failed to compare two elements in the array. occurred`
ViewModel.Events = new ObservableCollection<Event>(ViewModel.Events.OrderBy(x => new { x.LastName, x.FirstName }));
@Wietlol Find first checks the local cache and returns it, if it cannot be found then it will query the db.
we never used that :D
mr5
mr5
10:13
@ErwinOkken wait. Is this a DbSet of Company?
still the caching of the db context objects broke our applications
@mr5 Yes exactly. Not of CompanyBranche
ChangeTracking and lazy loading and stuff should be a death sentence :-P
@ErwinOkken you should do a saveChanges on the DbContext object
I do haha
mr5
mr5
@Xariez provide an comparable: stackoverflow.com/questions/985657/…
10:14
But without changetracking, that example is not working
then you have access to the DbSet of CompanyBranche
With changetracking, it is working.
Ahhw really
Then for now, let's fix the issue I had WITH changetracking :(
I assume CompanyBranche and Company are in the same db context
I am also not sure what this.dbSet is
I get an entity (will be tracked), I map it with automapper (to a new entity with the same ID), then I Update() and it whines about the ID already being tracked. I hate this :-P
this.dbSet is a DbSet<Company>. I do not have access to the rest of the dbsets. But I already know how I'm gonna fix that in the future (next sprint hopefully)
mr5
mr5
@Xariez or data.OrderBy(e => e.LastName, new YourComparatorHere())
10:17
https://stackoverflow.com/questions/50762966/exception-in-use-automapper-the-instance-of-entity-type-cannot-be-tracked-becau

That's my answer! ohhyeaa
mr5
mr5
@ErwinOkken see posting your query would get you answer. but that would resolve faster if you just give your db credentials
wat? so you only have problem with mapping?
ViewModel.Events = new ObservableCollection<Event>(ViewModel.Events.OrderBy(x => x.LastName)); - I tried doing this just to bypass the error for right now, but that doesnt seem to change anything either. Ideas? @mr5
My db credentials are root - root
My ip address is 127.0.0.1
mr5
mr5
@Xariez maybe they all have the same last name?
Yes the problem is because of automapper
        var currentObj = this._repository.GetById(obj.Id);
        currentObj = this._mapper.Map(obj, currentObj);
        currentObj.Country = null;
        this._repository.Update(currentObj);
        this._repository.SaveChanges();
        return currentObj;
10:25
They don't, but i'm also ordering by which room they are in if the user toggles the button again, and since that doesn't change anything, i'm pretty sure nothing associated with the ordering actually works
The first sentence attaches it to the database already. Then the repository wants to update currentObj, but that ID is already being tracked. So I get an error that it's already tracked. AutoMapper does not work by reference (SO post that I linked didn't work :S)
mr5
mr5
have you tried checking if the orderby really works?
I'll do that now.
Okay, yeah, the orderby does order the list
It's just not reflected on the view
mr5
mr5
try calling it in main thread
I mean, wrap the mutation in main thread
ObservableCollection is a SequentialCollection (or also known as a List)?
mr5
mr5
10:30
yes
It's just a list implemented with INotifyListPropertyChanged
for example, a HashSet could be observable, but it is not a list
ObservableCollection<T> is essentially a List<T>, except observable
HEY; IT WORKS
(why they haven't called it ObservableList<T> is beyond me)
again... I find the naming of collections in .net fairly vague
10:30
ViewModel.Events = new ObservableCollection<Event>(ViewModel.Events.OrderByDescending(x => x.LastName));
                DataList.ItemsSource = ViewModel.Events;
that sounds bad
like 7 bad
mr5
mr5
@Xariez pretty sure you're not using binding there
and you're not even on the ViewModel
and you're not even following MVVM
I am using a binding to set the itemssource to the datalist
But only initially
mr5
mr5
it should update
Should
mr5
mr5
10:32
no need to call the view from your ViewModel
I don't want to do it
But at this point,i have no idea how else to do it, after about a week of testing everything possible
mr5
mr5
also, try setting the Mode to TwoWay that is {Binding Events, Mode=TwoWay}
on a side note, why do events have a lastName?
mr5
mr5
yeah I was thinking about that earlier xD
Should be Event.User.LastName, but for whatever reason stripped it out
Event has EventTime, UserData and what time-interval it is in
UserData then has LastName, FirstName, those things
mr5
mr5
10:34
UserData should have PersonalInfo first, followed the LastName property
Not necessarely in our case
Anyhow, i tried setting Mode=TwoWay on the itemssource binding
No result
@mr5 followed by Text property
wait
mr5
mr5
but you're doing XF and MVVM wrong
there should also be a Name property between PersonalInfo and LastName
mr5
mr5
@Wietlol that's for the control
10:36
User -> UserData -> PersonalInfo -> Name -> LastName -> Text
The class is "better" than i'm making it out to be, but as an extremely sceptical person I don't want to share any info that could compromise anything (I know how silly it sounds, but that is the case)
that is why you should make an mcve
not an mvvm
mr5
mr5
we're just trivializing things. that should do
mr5
mr5
also, not mvc
10:39
But it's basically Event -> [Patient -> [ FirstName, LastName, Room, ListOfActivities -> [ Name, Type, Date, Status, ExtraInfo ], ExtraInfo, SSN], Time, Company, Interval]
Either way.
More ideas as to why my list is not updating? Because like I said, I'm all out of ideas myself @mr5
mr5
mr5
@Xariez have you tried updating it in main thread?
Not sure how to get a command to run on the main thread/synchronously tbh
And seeing how the toggle button is on the built in toolbar at the top, i don't have too many options
mr5
mr5
Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
        // update your list here
});
And that inside the Task i take it?
mr5
mr5
what do you mean?
just update your list there
10:44
As in, inside the asynchronous function?
So:

private async Task ToggleFilter() {
     Device.BeginInvokeOnMainThread(() => { });
}
If that is the case, that didn't change anything either, unfortunately
mr5
mr5
where are you calling this ToggleFilter?
On a command?
Yeah
this.ToolbarItems.Add(new ToolbarItem { Text = "A-Z", Command = new Command(async () => await ToggleFilter()), Order = ToolbarItemOrder.Primary });
mr5
mr5
oh sorry. I need to go. will reply after I got home
Aight! Nw
If it's later than in 3 hours i'll probably be gone as well for the weekend but yeah
This is interesting: If I do ViewModel.Events.Clear() it notices that.
What is problem?
10:52
TL;DR: XF3 ListView doesn't update when the associated ObservableCollection is re-sorted using Linq's .OrderBy()
Forcing me to set the ItemsSource manually via codebehind, which isn't very pretty
Orderby doesn't update the source collection though
ViewModel.Events = new ObservableCollection<Event>(ViewModel.Events.OrderByDescending(x => x.Patient.Name));
That should though, shouldn't it?
Yeah that should, but I'm not sure it updates immediately when the source is changed
Maybe try setting it to a new collection before adding the items
don't reassign collection unless Events itself is a notifying property
Events by itself is not a notifying property, no
or wait
Events is the ObservableCollection, but the items of the collection (Event) is not notifying
10:58
it doesn't matter that Events is an ObservableCollection<T>
if you do .Events = new whatever();, view won't notice
It won't ?
assignment is not an operation on an object, ObservableCollection<T> has no clue what variables it's assigned to
So how do you make it notice
Point made
Hm, OnPropertyChanged() doesn't do it
You'll have to find a way to notify it
Or sort the original collection instead of replacing it
Even if it involves making a new sorted collection, clearing the original and readding everything in the sorted order
I'm thinking about running all the way to the database-query and completely reloading the data
11:01
I tend to write an extension method that does collection.Clear(); foreach(var i in input) collection.Add(i);
Ideally the control should do the sorting itself but this is Xamarin forms so...
I was just gonna say.. We do have a CollectionHelper
@milleniumbug Some collecitons you can just do collection.AddRange(IEnumable<T>);
That takes a source and destinatino collection, clears the destination collection and adds everything from the sourcecollection to the destinationcollection
But I feel like i tried that without success..
@LeeButler unfortunately not ObservableCollection<T>
11:02
Yeah I couldn't remember if it did
this is where ObservableBatchCollection<T> comes in, sample implementation here github.com/milleniumbug/DidacticalEnigma/blob/master/…
ObservableCollection<Event> temp = new ObservableCollection<Event>(ViewModel.Events);
                temp.OrderBy(x => x.Patient.Name);

                CollectionHelper.TransferItems(temp, ViewModel.Events, true);
That doesnt seem to do it either, but i feel like its what you suggested?
tempis the sorted collection, CollectionHelper.TransferItems() clears the current collection then adds all items into it from the sorted one
LINQ operations don't modify the input collection in place
They return the new sequence
(Resharper warns about this btw)
I M M U T A B I L I T Y
LONG LIVE IMMUTABILITY
11:17
ALL HAIL IMMUTABILITY (it took me to realize there is a capslock on my keyboard until I pressed the T)
The first T or the last T?
first
So I'd need to do ObservableCollection<Event> temp = new ObservableCollection<Event>(ViewModel.Events.OrderBy(x => x.Patient.Name)); ? @milleniumbug
@milleniumbug is OrderBy and Select and Where even considered linq?
11:27
@Wietlol yes
because, afaik, linq is the syntax of from where select group by etc
THat's like, one half of linq
and OrderBy Select and Where doesnt use that syntax
The extension methods where/any/select/orderby/ etc are also linq
@Xariez That will make temp refer to the newly created observable collection of sorted events, yes
the query syntax is a fairly direct translation to equivalent method syntax
so yes, these are the part of LINQ, because that's what's executed
11:32
I'll be damned: it's actually updating!
Something funny is happening, but its updating!
ListOf(a, b, c) is a fairly direct translation to new List<Stuff>(a, b, c)
does that mean they can be considered the same?
@Xariez if something works without me understanding why, I do not consider it funny
@Wietlol I call that SQLinq
It's not that it's not working, it's just the first time i hit the toggle button, it fucks the time intervals, and when i hit it again, its back to working 100%
well, since this is a terminology question, you'd have to refer to what people call it
so... what MS does call it?
> .NET Language-Integrated Query defines a set of general purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language.
at the end of the page you have listed "Standard Query Operators in a Nutshell", and you have Where, Select/SelectMany, and so on listed
I'd say that if LINQ "defines" these, then yes, these are a part of it
+1 on that
¯\_(ツ)_/¯
this is a screencap of someone who lost the battle today
Case sensitivity too strong
The sad visage of surrendering.
@KamilSolecki it seems to me like a lot of the people you posted screenshots of had given up
11:46
@KamilSolecki too much Javaization
Somewhat, but this one clearly admitted that he can't anymore
he should try Java
he expressed his emotions through paint
he doesnt need upper case characters in the imports
which is clearly sad
11:47
Wait, what the fuck
I mean he is a Java developer
he has to be sad
ObservableCollection<Event> temp = new ObservableCollection<Event>(ViewModel.Events.OrderBy(x => x.EventTime).ThenByDescending(x => x.Patient.Room));
i am a Java developer
and i am often sad
but I am only sad because I am also a .NET developer
11:48
I do Java Scripting
JavaScript or Java Script?
How can that collection be (null), if it is used to populate another collection, which it does successfully?
TS, actually
\o/ TypeScript is amazing
Note though, don't google on 'ts playground'. You'll find something different entirely
You intrigue me
!!googleme ts playgronud
NOO
oh
i should not have clicked that
I warned you
i should not have clicked that
anyways
Googling for 'typescript playground' is perfectly fine. The first hit is this nice sandbox where you can play.
stepping away from adult toys
11:50
Imagine me going 'ts playground' and blindly clicking the first link? Yeah.
At work. That happened.
lmaoo
Is the site NSFW as well?
Like.. immediately?
Very very very NSFW
I see
well duh
Well i would atleast expect an age gate or of the sort
Because you know
Those help
11:51
@Xariez nice spleilng
I don't remember the last time I did see an age gate.
Ubisoft still has it me thinks?
Same goes for steam
I'm always logged in on Steam, so I don't see it. Ubisoft I don't use
i dont use anything made by someone else
except for stack overflow
Visit the store page of a 18+ game and you'll see it
11:53
and chrome
and kotlin
and ms paint
and rider
hmm... those two as well
!!wietlol2
@Xariez I only play all audience games.
11:54
!!wietlol2
Sep 13 '17 at 15:07, by Wietlol
i will most probably write my own
@Xariez I would never play a game with sexual content. No, sir. Never. I swear.
2
my favorite game on steam is lolipop simulator
my favorite game on steam is the search page
11:59
Did you build your own phone and write the OS for it?
Your own house? car?
@KamilSolecki can't find it

« first day (2855 days earlier)      last day (2319 days later) »