✅ Shorten data querying line

Hi, how do I shorten this line that's querying for data? Like, instead of putting them into one long line, I'm looking to separate them, is it something like
var cityOneBlock = _context.CityBlocks.Where(x => x.Location == Location.One)
var cityTwoBlock = _context.CityBlocks.Where(x => x.Location == Location.Two)

var cityBlocks = _context.CityBlocks.Where(cityOneBlock || cityTwoBlock).ToList();
var cityOneBlock = _context.CityBlocks.Where(x => x.Location == Location.One)
var cityTwoBlock = _context.CityBlocks.Where(x => x.Location == Location.Two)

var cityBlocks = _context.CityBlocks.Where(cityOneBlock || cityTwoBlock).ToList();
3 Replies
Patrick
Patrick2y ago
The question doesn't really make sense.
var cityBlocks = _context.CityBlocks.Where(x => x.Location == Location.One || x.Location == Location.Two).ToList();
var cityBlocks = _context.CityBlocks.Where(x => x.Location == Location.One || x.Location == Location.Two).ToList();
alternatively, if you really must not have an OR
var locations = new[] { Location.One, Location.Two };
var cityBlocks = _context.CityBlocks.Where(x => locations.Contains(x.Location)).ToList();
var locations = new[] { Location.One, Location.Two };
var cityBlocks = _context.CityBlocks.Where(x => locations.Contains(x.Location)).ToList();
CoreVisional
CoreVisional2y ago
Ahh, this is what I was looking for Thank you, and sorry for the confusing title btw
Accord
Accord2y ago
Closed!
Want results from more Discord servers?
Add your server
More Posts
❔ Blazor JS Interop - Return RTCPeerConnection from js to Blazor in order to close itHi, I've quite a complex task: In my Blazor application I use javascript to read webrtc data produce✅ Authentication with CookiesI'm playing around with cookies to get a better understanding. My code: ``` var builder = WebApplic❔ need help with visual studio communityhi i have multipul q 1- i have mac is there way to have community on it 2- please hoe to make 3 buUsing the new INumber interface to determine if an object is a number without having the generic argWith .net7 we now have the INumber<TSelf> interface which is pretty cool, and I thought I found a pl✅ Polyphormism?Is this polyphornism? I am not sure, I was told I should make something like this ```cs public abst❔ I'm not sure what's wrong with my codeI don't know why Thompson still pop up only T should be. (The blue outline is what I'm trying to do)✅ WPF Build size triples after changing target framework to net6.0-windows10.0.17763.0Hello. My WPF application uses .net6 and recently I was asked to use 'toast' style Windows 10/11 notASP Web-API with MessageBroker - Post was processed, what now?I'm trying to seperate the ASP Web-API from the workers which interact with the daterbase using Rabb✅ Trying to display a string backwards and lower caseAnd I don't understand on how to use Reverse() method❔ How do these SQL queries work?I'm honestly at a loss and can't figure out the process for these queries and how they work. (Note