0

I'm doing a project and i need something like a select where like of sql server but in the get function of asp.net async task IActionResult.

I have solved the problem using a IndexOf in the where of the query but i don't know if there's the right way or if there are other ways to do the same thing.



// GET api/<ValuesController>/5
        [HttpGet("{id}")]
        public async Task<IActionResult> Get(string id)
        {

            Array[] myIntArray = new Array[1];
            try
            {
                var query = from ms in _context.MaterialSalida
                            where ms.NoLote.IndexOf(id) > -1
                            select new
                            {
                                Pk_MaterialSalida = ms.Pk_MaterialSalida,
                                Fk_CorridaExtrusion = ms.Fk_CorridaExtrusion,
                                PesoNetoRollo = ms.PesoNetoRollo,
                                NoLote = ms.NoLote,
                                UbicacionNumero = ms.UbicacionNumero,
                                FechaIngreso = ms.FechaIngreso
                            };

                var listMaterialSalidaD = await query.ToListAsync().ConfigureAwait(false);
                myIntArray[0] = new[] { listMaterialSalidaD };




            }
            catch (Exception ex)
            {

                return BadRequest(ex.Message);
            }


            return Ok(myIntArray);


        }



  • welcome to so, take a look here: https://stackoverflow.com/questions/1033007/like-operator-in-entity-framework – Isparia Jun 02 '22 at 14:18

0 Answers0