Reputation: 686
I'm writing Api with Visual Studio, but I get errors.
Login login = new Login();
//set some properties
db.Logins.Add(login);
db.SaveChanges();
'IEnumerable' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?)
And:
var user = db.Logins.Where(x => x.UserName == username &&
x.Password == password).FirstOrDefault();
'object' does not contain a definition for 'UserName' and no extension method 'UserName' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Please help me.
Upvotes: 0
Views: 4252
Reputation: 191
IEnumerable is an interface that contains a single method Enumerator GetEnumerator();. Which makes IEnumerable read-only.
Use ICollection to Add item in a collections.
Check if you import this namespaces:
System.Collections.Generic;
System.Linq;
Upvotes: 1