2

I am going crazy trying to get a handle on Linq include.

My main file is "Application" that has a GUID key of "Id" but I can't figure out the syntax to get it back without error.

public static Guid? ApplicationIdGet(string pApplicationName)
{
    return BrunoEntities.Set<AppApplication>().Include("Id").FirstOrDefault(p => p.LoweredName == pApplicationName.ToLower()).Id;
    //return BrunoEntities.AppApplications.Include(a => a.Id).FirstOrDefault(p => p.LoweredName == pApplicationName.ToLower()).Id;
    //return brunoEntities.AppApplications.Include("Id").FirstOrDefault(p => p.LoweredName == pApplicationName.ToLower()).Id;
}

1 Answer 1

2

Include is for where you want EF to load in related entities. You don't need it to get normal properties of the entity you are requesting. If you do want to have EF only fetch certain columns from the database, the Select function will let you control that

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.