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
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();