0
I have a problem, I need to make a filter with a list of strings that comes as parameter with a icollection
, the visual studio accuses
"Cannot Convert from List to Unidadefederativaforedor"
What could be done in this case? This is the code:
public HttpResponseMessage GetPotenciaisFornecedoresProduto(int id, [FromUriAttribute] List<int> marcas, int dias, List<string> unfed ,int? take = 20, int skip = 0)
{
DateTime dataDaOperacao = DateTime.Now;
dataDaOperacao = dataDaOperacao.AddDays(-dias);
var ofertas = FornecedorCotacaoService.GetAll()
.Where(c => c.FornecedorProdMarcaCotacao.Any(o => o.ProdutoMarca.IdProduto == id
&& (marcas.Contains(o.ProdutoMarca.IdMarca)
&& (c.Cotacao.DtCadastro >= dataDaOperacao)
&& *c.Fornecedor.UnidadeFederativaFornecedor.Contains(unfed)*)
))
.GroupBy(c => new { c.IdFornecedor, c.Fornecedor.Pessoa.NmPessoa, c.Fornecedor.Pessoa.EnderecoFatura.IdUnidadeFederativa })
.Select(c => new { c.Key.IdFornecedor, c.Key.NmPessoa, c.Key.IdUnidadeFederativa, Count = c.Count() })
.ToList();
If you look at the documentation you will see that the contains is as follows List<T>. Contains(T) being the’T' type in question, note that in your case you are picking up a list of the type Unidadefederativaforedor and this trying to use contains with a list of strings
– Lucas Miranda
Any hints of what could be done ?
– Silvio Fernando