私は再び申し訳ないが、私の最初の質問のこの質問継続: このインタフェースを検討:戻り値の型
interface IRepository<T,U> where T:class where U:class
{
IEnumerable<U> SelectAll();
bool Insert(T item);
IEnumerable<T> FindAll(Func<T, bool> exp);
}
を、私はこのインタフェースを実装します。
public class Repository : IRepository<Customer,Select4ColumnsOfCustomers>
{
#region IRepository<Customer,Select4ColumnsOfCustomers> Members
public IEnumerable<Select4ColumnsOfCustomers> SelectAll()
{
throw new NotImplementedException();
}
public bool Insert(Customer item)
{
throw new NotImplementedException();
}
public IEnumerable<Customer> FindAll(Func<Customer, bool> exp)
{
throw new NotImplementedException();
}
#endregion
}
public class Select4ColumnsOfCustomers
{
public int CustomerID { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string Phone { get; set; }
}
私がしたいですnorthwindデータベースのCustomerテーブルのちょうど4列を返します。 Ok.this仕事が、私は、私はSを宣言する必要があり、他のタイプを返す他の方法で、Uを追加したい場合は、M、W、...インターフェイスで、私はこのコードを記述する必要があり、それの実装で:
public class Repository : IRepository<Customer,RetType1,RetType2,RetType3,....>
これは良くありません。これに代わるものは何ですか?返り値の型にはvarを書くことができますか?戻り値の型はプレースホルダですか? ありがとう
この種のものには、「Datatable」またはORMを使用することを検討してください。 – nan