Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is this OK or is there a better way to write?
Message
From
01/06/2018 03:09:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
C#
Category:
LINQ
Miscellaneous
Thread ID:
01660495
Message ID:
01660498
Views:
53
>Hi everybody,
>
>I'm just wondering if you think this is OK as is or should be changed?
>
>
>public IEnumerable<RsTsBlocks> GetBlocksInSection(int sectionId)
>        {
>            return _rsTsBlocksRepository.GetBlocksInSection(sectionId)
>                .Cast<RsTsBlocks>()
>                .Select(x => { x.CenterMost = x.CenterMost == "C" ? Labels.centerSeat : (x.CenterMost == "E" ? Labels.endSeat : Labels.startSeat);
>                    return x; })
>                .ToList();
>        }
>
>I have only 3 cases (C/S/E) and I want to return back the correct description translated. Does the above code look OK or should it be somehow changed?
>
>Thanks in advance.

For this to work at all, GetBlocksInsection should be returning local data (an IEnumerable and not an IQueryable). Other than that you are doing a transformation on a member. If this list wouldn't need to be saved or again a transformation made on save then it should be OK. Since this seems to be only for display purposes, I would personally do this on the UI instead.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform