7
I have this data model and I don’t know how to do the instruction lambda:
public class CidadeAbrangencia
{
[Key]
public int CidadeAbrangencia_Id { get; set; }
public string CEPInicial { get; set; }
public string CEPFinal { get; set; }
}
Example, I need to search all Zip Codes that start at 03500-000 up to 04000-000.
Consultation:
IEnumerable<CidadeAbrangencia> retAbrangencia = context.CidadeAbrangencias.Where(x => x.CEPInicial >= '03500-000' && '04000-000');
My problem is that the CEP Inicial and the ZIP CODE are guys string
, then how to do?
Being String gives error:
The >= operator cannot be applied to string and sgtring type operands
But data type error occurs: The >= operator cannot be applied to strings and sgtring operands
– hard123
I edit the post and added the error message
– hard123
Huh? There’s the operator
>=
forstring
andstring
?– Jéf Bueno
I think that operator
>=
does not work for String.– gato
Exactly @gato ! does not work ! And how can I get around this problem ?
– hard123
@LINQ Oops, wrong language :D
– Maniero
@adrianojc Ou vc converts using the
TryParse
(I don’t think it’s a good idea) or you will have to elaborate an extension method. But there must be something native to this, you have to check the documentation first.– gato
@Maniero I even went to look in C# 8 to see if there was something =D It’s probably Kotlin
– Jéf Bueno