Может ли кто-нибудь рассказать мне, как заполнить поля в моем интерфейсе IAccount
? У меня ошибка в x.Add(new IAccount ...
Populating Interface
public class IPersonRepo : IAccount
{
string connectionstring = @"Server=SLI002/SQLEXPRESS;Database=atengturonDB;Trusted_Connection=true;";
public int AccountsID
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public byte[] AccountUserName
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public byte[] AccountPassword
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public byte[] AccountSalt
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public void getAccount()
{
SqlConnection conn = new SqlConnection(connectionstring);
using (SqlCommand comm = new SqlCommand())
{
List<IAccount> x = new List<IAccount>();
comm.Connection = conn;
comm.CommandText = "Select AccountsID,AccountsUserName,AccountsPassword,AccountsSalt from Accounts";
comm.CommandType = CommandType.Text;
SqlDataReader reader = null;
conn.Open();
comm.ExecuteNonQuery();
reader = comm.ExecuteReader();
while (reader.Read())
{
x.Add(new IAccount
{
AccountsID = (int)reader["AccountsID"],
AccountUserName = (byte[])reader["AccountsUserName"],
AccountPassword = (byte[])reader["AccountsPassword"],
AccountSalt = (byte[])reader["AccountsSalt"]
});
}
conn.Close();
}
}
}
Вы не можете создавать интерфейсы. – CodeCaster
Как насчет переименования 'IPersonRepo' в класс PersonAccount: IAccount' - then' x.Add (new PersonAccount'? – StuartLC
ваши методы-установки не реализованы –