8
I’m doing tests with Entity Framework and I had a problem when placing a array as a parameter.
Why when I assign the conversion of array in a function variable and directly in the method parameter does not work?
This behavior is normal?
If yes, what name?
Works
List<Product> product = new List<Product>()
var p = product.ToArray();
db.Product.AddOrUpdate(x => x.Id, p);
Doesn’t work
List<Product> product = new List<Product>()
db.Product.AddOrUpdate(x => x.Id, product.ToArray());
Doesn’t work like? It’s certainly not because of missing one
)
indb.Product.AddOrUpdate(x => x.Id, product.ToArray();
or is?– ramaral
This is not why. When it is converted into the parameter it just does not insert, it does not give any error.
– Jean Gustavo Prates
You have how to explain how this variable
product
is formed?– Leonel Sanches da Silva
@I edited the question.
– Jean Gustavo Prates
But you don’t need to convert to array to use
AddOrUpdate
. And the list is empty. This is correct?– Leonel Sanches da Silva
@Ciganomorrisonmendez the list comes through a Post, put only to identify that is a list of objects. Addorupdate expects a Product type array (params Product[]).
– Jean Gustavo Prates