Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcludeProperty instead of Select() inclusively per query #22683

Closed
jsheely opened this issue Sep 23, 2020 · 1 comment
Closed

ExcludeProperty instead of Select() inclusively per query #22683

jsheely opened this issue Sep 23, 2020 · 1 comment

Comments

@jsheely
Copy link

jsheely commented Sep 23, 2020

I would like to be able to exclude certain properties from the SQL that is fetched without having to inclusively add each property I want in a .Select()

Example:

// Model
public class Product {
    public int Id {get;set;}
    public string Name {get;set;}
    public string BigBloatedJson {get;set;}
}

// Exclude BigBloatedJson property to get (select Id, Name from Product where Id =@Id)
dbContext.Product.Where(x => x.Id == Id).ExcludeProperty(x => x.BigBloatedJson).FirstOrDefault();

// Instead of what you have to do now
dbContext.Product.Where(x => x.Id == Id).Select(x => new Product {Id = x.Id, Name = x.Name}).FirstOrDefault();

In this simple example I only have a couple properties. But in a larger entity and one that make have base class inheritance it becomes much more tedious.

Is this even possible with the current architecture? Has anyone done it? Is there a better way?

@ajcvickers
Copy link
Contributor

Duplicate of #1387

@ajcvickers ajcvickers marked this as a duplicate of #1387 Sep 25, 2020
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants