Ziomek64
Ziomek64
CC#
Created by Ziomek64 on 5/28/2023 in #help
❔ A property is changed even though it shouldn't?
This is driving me absolutely bonkers but something weird is going on.
else
{
GraphQLResponse<Data> filt = apiListData;

GraphQLResponse<Data> startFilter = filt;

foreach (var List in startFilter.Data.MediaListCollection.lists)
{
foreach (var listEntry in List.entries)
{
listEntry.CustomListsList = new ObservableCollection<customListItem>();
if (listEntry.CustomLists != null)
{
foreach (var VARIABLE in listEntry.CustomLists)
{
listEntry.CustomListsList.Add(
new customListItem
{
key = VARIABLE.Key,
value = VARIABLE.Value
}
);
}
}
}
}

var filtered = startFilter.Data.MediaListCollection.lists;

foreach (var x in filtered)
{
x.entries = x.entries.Where(x => x.media.Title.UserPreferred.ToLowerInvariant().Contains(query))
.ToList();
}
Console.WriteLine(filtered);
else
{
GraphQLResponse<Data> filt = apiListData;

GraphQLResponse<Data> startFilter = filt;

foreach (var List in startFilter.Data.MediaListCollection.lists)
{
foreach (var listEntry in List.entries)
{
listEntry.CustomListsList = new ObservableCollection<customListItem>();
if (listEntry.CustomLists != null)
{
foreach (var VARIABLE in listEntry.CustomLists)
{
listEntry.CustomListsList.Add(
new customListItem
{
key = VARIABLE.Key,
value = VARIABLE.Value
}
);
}
}
}
}

var filtered = startFilter.Data.MediaListCollection.lists;

foreach (var x in filtered)
{
x.entries = x.entries.Where(x => x.media.Title.UserPreferred.ToLowerInvariant().Contains(query))
.ToList();
}
Console.WriteLine(filtered);
I'm making a local variable at the beginning to which I assign data from apiListData. I'm making some changes on that local variables, especially that foreach (var x in filtered) which filters data. When I do debug point on that console.writeline apiListData from the beginning which was accessed only is affected even though it shouldn't. And don't mind second local variable, I was doing it only to avoid this weird situation kekw Whole .cs - https://pastebin.com/4pezNHzB apiListData is just raw data that I'm assigning in Refresh task to keep it for filtering purposes.
59 replies