EntityBuilderのS2Dao.NET対応
元々、EntityBuilderを作成したのは、S2Dao.NETのためだったりします。Entityクラスを作るだけでなく、対応するインタフェースまで自動生成して完成です。ちょっと時間が掛かりましたが、やっと目的を達成しました。
次のようなcreate table文があった場合、
create table Quotations (
suppno char(3) not null,
partno char(4) not null,
price integer,
responsetime integer,
primary key (suppno, partno));
-- プライマリキーがない
create table Orders (
suppno char(3) not null,
partno char(4) not null,
quantity integer,
orderdate Date);
create table Suppliers (
suppno char(3) primary key,
name varchar(35),
address varchar(35));
Entityクラス及び、Daoインタフェースを作成します。メソッドは挿入、更新、削除及び、全件検索。プライマリキーを持つテーブルの場合は、キーによる検索も生成します。
//------------------------------------------------------------------------------ // <auto-generated> // このコードはツールによって生成されました。 // ランタイム バージョン:2.0.50727.42 // // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 // コードが再生成されるときに損失したりします。 // </auto-generated> //------------------------------------------------------------------------------ namespace BuilderTest { [System.SerializableAttribute()] public partial class Quotations { private string _suppno; private string _partno; private System.Nullable<int> _price; private System.Nullable<int> _responsetime; public string Suppno { get { return this._suppno; } set { this._suppno = value; } } public string Partno { get { return this._partno; } set { this._partno = value; } } public System.Nullable<int> Price { get { return this._price; } set { this._price = value; } } public System.Nullable<int> Responsetime { get { return this._responsetime; } set { this._responsetime = value; } } } [Seasar.Dao.Attrs.Bean(typeof(Quotations))] public partial interface IQuotationsDao { int Insert(Quotations quotations_); int Update(Quotations quotations_); int Delete(Quotations quotations_); Quotations Select(); Quotations SelectByKey(string suppno, string partno); } [System.SerializableAttribute()] public partial class Orders { private string _suppno; private string _partno; private System.Nullable<int> _quantity; private System.Nullable<System.DateTime> _orderdate; public string Suppno { get { return this._suppno; } set { this._suppno = value; } } public string Partno { get { return this._partno; } set { this._partno = value; } } public System.Nullable<int> Quantity { get { return this._quantity; } set { this._quantity = value; } } public System.Nullable<System.DateTime> Orderdate { get { return this._orderdate; } set { this._orderdate = value; } } } [Seasar.Dao.Attrs.Bean(typeof(Orders))] public partial interface IOrdersDao { int Insert(Orders orders_); int Update(Orders orders_); int Delete(Orders orders_); Orders Select(); } [System.SerializableAttribute()] public partial class Suppliers { private string _suppno; private string _name; private string _address; public string Suppno { get { return this._suppno; } set { this._suppno = value; } } public string Name { get { return this._name; } set { this._name = value; } } public string Address { get { return this._address; } set { this._address = value; } } } [Seasar.Dao.Attrs.Bean(typeof(Suppliers))] public partial interface ISuppliersDao { int Insert(Suppliers suppliers_); int Update(Suppliers suppliers_); int Delete(Suppliers suppliers_); Suppliers[] Select(); Suppliers SelectByKey(string suppno); } }
ここまで自動生成されます。パーシャルクラスなので拡張も可能。
さて、形は出来たので後はテスト。今、公開しているEntityBuilderも結構、バグがあるし。(^^;
(追記)自動生成されるコードを修正。