A
A
Alyosha2018-03-03 09:33:44
ASP.NET
Alyosha, 2018-03-03 09:33:44

How to correctly make a fetch in this request on asp.net core 2.0? web api?

I want to make a selection by two fields, is it by the text field and by the record ID?
and I have this code:

var get_like = db.Like.Count(t => t.Text == 'mytext');

It works cool, but how can I specify, for example, 2 parameters for the selection?
var get_like = db.Like.Count(t => t.Text == 'mytext', t.Two == 'd');

it doesn't work, the syntax is not correct
Everything happens in WebAPI
[HttpPost("Name/{id}")]
        public IActionResult Name(int id)
        {
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman, 2018-03-03
@yarosroman

var get_like = db.Like.Count(t => t.Text == 'mytext' || t.Two == 'd');

E
eRKa, 2018-03-03
@kttotto

var get_like = db.Like.Where(t => t.Text == 'mytext' && t.Two == 'd').Count();
или
var get_like = db.Like.Count(t => t.Text == 'mytext' && t.Two == 'd');

D
Dmitry Bashinsky, 2018-03-03
@BashkaMen

var likeCount = db.Like.Count(t => t.Text == 'mytext' && t.Two == 'd');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question