Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kurnakovv/smartselector
SmartSelector is open source library that allows you to get the specific object fields without a "Select" method.
https://github.com/kurnakovv/smartselector
csharp nuget
Last synced: about 2 months ago
JSON representation
SmartSelector is open source library that allows you to get the specific object fields without a "Select" method.
- Host: GitHub
- URL: https://github.com/kurnakovv/smartselector
- Owner: kurnakovv
- License: mit
- Created: 2023-09-28T13:47:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-28T05:16:49.000Z (12 months ago)
- Last Synced: 2024-12-15T01:08:27.688Z (about 2 months ago)
- Topics: csharp, nuget
- Language: C#
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
SmartSelector
[![NuGet](https://img.shields.io/nuget/v/Kurnakov.SmartSelector.svg)](https://www.nuget.org/packages/Kurnakov.SmartSelector)
[![NuGet download](https://img.shields.io/nuget/dt/Kurnakov.SmartSelector.svg)](https://www.nuget.org/packages/Kurnakov.SmartSelector)
![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%kurnakovv%SmartSelector&countColor=%23263759&style=flat)
[![MIT License](https://img.shields.io/github/license/kurnakovv/SmartSelector?color=%230b0&style=flat)](https://github.com/kurnakovv/SmartSelector/blob/main/LICENSE)
[![Build/Test](https://github.com/kurnakovv/SmartSelector/actions/workflows/build-test.yml/badge.svg)](https://github.com/kurnakovv/SmartSelector/actions/workflows/build-test.yml)# Description
SmartSelector is open source library that allows you to get the specific object fields without a "Select" method.# Idea
Code taken from https://stackoverflow.com/questions/54549506/select-only-specific-fields-with-linq-ef-core# How is it work
```cs
public class MyTestObject
{
public string FirstProperty { get; set; }
public string SecondProperty { get; set; }
public string ThirdProperty { get; set; }
}IQueryable myTestObjects = new List()
{
new MyTestObject { FirstProperty = "a1", SecondProperty = "a2", ThirdProperty = "a3", },
new MyTestObject { FirstProperty = "b1", SecondProperty = "b2", ThirdProperty = "b3", },
new MyTestObject { FirstProperty = "c1", SecondProperty = "c2", ThirdProperty = "c3", },
}.AsQueryable();
IQueryable result = myTestObjects.SelectFields(new List() { "SecondProperty", "ThirdProperty" });// Output
FirstProperty: null (default), SecondProperty: 'a2', ThirdProperty: 'a3'
FirstProperty: null (default), SecondProperty: 'b2', ThirdProperty: 'b3'
FirstProperty: null (default), SecondProperty: 'c2', ThirdProperty: 'c3'
```# Give a star ⭐
I hope this library is useful for you, if so please give a star for this repository, thank you :)