1

Given the following SQL statement in classic ASP, what would your translation into Linq be like?

sq = " select cod_troquel, referencia, fila, columna, dimX, dimY, ancho, avance, calleVertical, calleHorizontal, pinzaIzquierda, pinzaDerecha, tt.nombre, ett.nombre, pinzaSuperior, pinzaInferior,radioCantos, convert(tinyint, t.regular), fichero, t.observaciones, t.nEjemplares, t.aplicarPrecioGolpe, t.golpes, app.tipoPagina "&_
     " from agrupacionProductoProducto app "&_
     " inner join troquelAPP tapp on tapp.agrupacionProductoProducto=app.cod_agrupacionProductoProducto "&_
     " inner join etTroquel t on t.cod_troquel=tapp.troquel "&_
     " left join etTipoTroquel ett on ett.cod_etTipoTroquel = t.tipoTroquel2 "&_
     " left join tipoTroquel tt on tt.cod_tipoTroquel = t.tipoTroquel "&_
     " where t.usoArchivo=1 and t.ideal=0 and t.baja=0 and app.cod_agrupacionProductoProducto="&codigo

if tipoPagina=1 then 'LAMINA SIMPLE
    sq = sq & " and t.regular = 0"
else 'ETIQUETA
    sq = sq & " and t.regular = 1"
end if

sq = sq & " order by upper(referencia)"

My problem in particular is with the where there are in the if, in how they are added

1 Answer 1

3

basically in entity framework you can build firstly query

var query = _dbContext.Users.Where(u => u.Name == "Josh");

then you can update query

if(!string.IsNullOrEmpty(lastName)){
     query = query.Where(u => u.LastName == lastName);
}
return query.ToList();
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.