Home > Net >  Query many values into one request - entity framework
Query many values into one request - entity framework

Time:02-23

i am new to the entity framework. i want so find a spezific database item...

i used this code

using (var db = new DatabaseX(_connectionVar))
            {
                try
                {
                    var data = from test in db.X where test.Y== Y && test.z== z && test.s== s select test;

                }
            }

but how can i combine this parameters? With the sign "&&" it doesn´t work...

I hope someone can help me.

CodePudding user response:

So if you are using entity framework you first want to make a db context: https://docs.microsoft.com/en-us/ef/ef6/fundamentals/working-with-dbcontext.
Then you want to make some sort of repository where you can get your data:

return await dbContext.test
            .Where(test => test.X == X)
            .Where(test => test.Y == Y)
            .Where(test => test.Z == Z)
            .FirstOrDefault();

But reading and following the fundamentals on https://docs.microsoft.com/en-us/ef/ef6/ should be a big help.

  • Related