Hello, I ran into a problem, my code looks somehow cumbersome. Because of the condition by which I want to select records from a specific table. I have a table, I do a selection of 2 string fields (EventName, VenueName). There are also some input data (the names for which I search, let's say at the input EN = 'MyEvent' and VN = 'MyVenue') I need to select the records where
EventName == EN & VenueName == VN + must be added to the sample record, where
EventName == EN & VenueName == null or
EventName == null & VenueName == VN. Those. just write
EventName == EN | VenueName == VN EventName == EN | VenueName == VN fail. Is it possible to somehow better write this expression easier than mine?
dynamicNotes = dynamicNotes.Where( x => ((x.VenueName.Equals(searchModel.VenueName)) && (x.EventName.Equals(searchModel.EventName))) || (x.VenueName.Equals(searchModel.VenueName)) && (string.IsNullOrEmpty(x.EventName)) || (x.EventName.Equals(searchModel.EventName)) && (string.IsNullOrEmpty(x.VenueName)));
Equalson properties that can benull. - Alexander Petrov