爽歪歪,三层架构下的实体类生成工具(50)

  • 主题发起人 wpy020327
  • 开始时间
W

wpy020327

Unregistered / Unconfirmed
GUEST, unregistred user!
GetEntity.exe是一个实体类代码生成器,能自动生成三层架构下的远程数据库实体类单元代码(基于QB中间件)。下面是自动生成的一个实体类的声明部分:
//// ------------------------------------------------------------------------------------//// Entity_Orders.pas -- This entity class unit for table "Orders". //// Generated by QuickBurro V3.04 Entity Classes Generator//// Generate time: 2009-05-29 11:47:28//// Copyright (C) Jopher Software Studio, 2006-2009 //// ------------------------------------------------------------------------------------//unit Entity_Orders;interfaceuses SysUtils, Classes, db, DBClient, SyncBurro, QBParcel;type TOrders = class(TPersistent) Private ff_OrderID: Integer; ff_CustomerID: String; ff_EmployeeID: Integer; ff_OrderDate: TDateTime; ff_RequiredDate: TDateTime; ff_ShippedDate: TDateTime; ff_ShipVia: Integer; ff_Freight: Double; ff_ShipName: String; ff_ShipAddress: String; ff_ShipCity: String; ff_ShipRegion: String; ff_ShipPostalCode: String; ff_ShipCountry: String; class function CreateCds: TClientDataset; class function ReadFromCds(aCds: TClientDataset): TOrders; public Property f_OrderID: Integer read ff_OrderID write ff_OrderID; Property f_CustomerID: String read ff_CustomerID write ff_CustomerID; Property f_EmployeeID: Integer read ff_EmployeeID write ff_EmployeeID; Property f_OrderDate: TDateTime read ff_OrderDate write ff_OrderDate; Property f_RequiredDate: TDateTime read ff_RequiredDate write ff_RequiredDate; Property f_ShippedDate: TDateTime read ff_ShippedDate write ff_ShippedDate; Property f_ShipVia: Integer read ff_ShipVia write ff_ShipVia; Property f_Freight: Double read ff_Freight write ff_Freight; Property f_ShipName: String read ff_ShipName write ff_ShipName; Property f_ShipAddress: String read ff_ShipAddress write ff_ShipAddress; Property f_ShipCity: String read ff_ShipCity write ff_ShipCity; Property f_ShipRegion: String read ff_ShipRegion write ff_ShipRegion; Property f_ShipPostalCode: String read ff_ShipPostalCode write ff_ShipPostalCode; Property f_ShipCountry: String read ff_ShipCountry write ff_ShipCountry; constructor Create; destructor Destroy; override; procedure CloneTo(TargetObj: TOrders); class function ReadFromDB(NodeId: String; SBurro: TSyncBurro; Condition: String): TOrders; class function DeleteFromDB(NodeId: String; SBurro: TSyncBurro; Condition: string): boolean; function InsertToDB(NodeId: String; SBurro: TSyncBurro): boolean; function UpdateToDB(NodeId: String; SBurro: TSyncBurro; Condition: string): boolean; end; TOrdersList = class(TList) public constructor Create; destructor Destroy; override; class function ReadFromDB(NodeId: String; SBurro: TSyncBurro; Condition: string = ''; OrderBy: string = ''): TOrdersList; class function DeleteFromDB(NodeId: String; SBurro: TSyncBurro; Condition: string): boolean; function WriteToDB(NodeId: string; SBurro: TSyncBurro; TargetTable: string): boolean; function SaveToFile(FileName: string; DataFormat: TDataPacketFormat): boolean; function LoadFromFile(FileName: string): boolean; function SaveToStream(aStream: TMemoryStream; DataFormat: TDataPacketFormat): boolean; function LoadFromStream(aStream: TMemoryStream): boolean; function SaveToParcel(aParcel: TQBParcel; GoodsName: string): boolean; function LoadFromParcel(aParcel: TQBParcel; GoodsName: string): boolean; end;implementation​
 
不知所云,命名都不按约定来,自来一套别人很难实应看着就头大
 
参照下橙子的Dhibernate,就什么都会写了。
 
腐儒作风:TOrders = class(TPersistent) Private class function CreateCds: TClientDataset; class function ReadFromCds(aCds: TClientDataset): TOrders; public ff_OrderID: Integer; ff_CustomerID: String; ff_EmployeeID: Integer; ff_OrderDate: TDateTime; ff_RequiredDate: TDateTime; ff_ShippedDate: TDateTime; ff_ShipVia: Integer; ff_Freight: Double; ff_ShipName: String; ff_ShipAddress: String; ff_ShipCity: String; ff_ShipRegion: String; ff_ShipPostalCode: String; ff_ShipCountry: String; constructor Create; destructor Destroy; override; procedure CloneTo(TargetObj: TOrders); class function ReadFromDB(NodeId: String; SBurro: TSyncBurro; Condition: String): TOrders; class function DeleteFromDB(NodeId: String; SBurro: TSyncBurro; Condition: string): boolean; function InsertToDB(NodeId: String; SBurro: TSyncBurro): boolean; function UpdateToDB(NodeId: String; SBurro: TSyncBurro; Condition: string): boolean; end;
 
[:D]三层下的实体类,自然与两层的有所不同,因为所基于的中间层不同。搞这个: Property f_OrderID: Integer read ff_OrderID write ff_OrderID; Property f_CustomerID: String read ff_CustomerID write ff_CustomerID; Property f_EmployeeID: Integer read ff_EmployeeID write ff_EmployeeID; ...目的是为可能的实体类代码修改提供方便,并不是脱裤子放P这么简单。
 
顶部