Skip to content

Basic queries

SQLBuilder

  • Use when you have tables but no entity classes.
  • Highly flexible for complex SQL.
  • Good for changing requirements or minimal setups.
c#
var dt = kit.select("t.ZH_TroubleOID as oid, t.T_Title, t.T_OrgName")
    .from("ZH_Trouble t")
    .where("t.T_Status= 1")
    .orderby("t.SYS_Created desc")
    .top(6)
    .query();

Repository

Use repository rep for common CRUD.

  • Requires entity types
  • Fast for typical operations
  • Less flexible for exotic conditions
  • Complexity: low
c#
<List<SysRegion> list= rep.GetList(u => u.Pid == input.Id);

SQLClip

SQLClip mirrors SQLBuilder’s style but uses entity-based APIs instead of raw SQL fragments.

  • Requires entity types
  • Medium flexibility
  • Medium complexity
  • No magic SQL strings
c#
var cmd= clip.from<HHDutyItem>(out var a)
    .where(() => a.Di_Name == "1")
    .whereIn(()=>a.Di_Idx, new List<int?> { 1,3 })
    .select(()=> a)
    .toSelect();

Shortcuts

Extended helpers on SQLBuilder; no shared context.

  • Entity-based
  • Custom conditions
  • List / single / update / delete helpers

List

c#
var list = kit.findList<HHDutyItem>((c,h)=>c.where(()=>h.Di_Idx,0));

By IDs:

c#
var list = kit.findListByIds<HHDutyItem>("0001,0002");

Single row

Returns null if not unique:

c#
var row = kit.findRow<HHDutyItem>((c, h) => c.where(() => h.HH_DutyItemOID, "0001"));

Single field

c#
var val = kit.findFieldValue(oid,(SQLClip c,HHDutyItem h) => c.select(() => h.HH_DutyItemOID));

var val = kit.findFieldValue<HHDutyItem,string>(oid, (c,h) => c.select(() => h.HH_DutyItemOID));

var val = kit.findFieldValue(oid,(HHDutyItem h) => h.Di_Note);

var val = kit.findFieldValue<HHDutyItem,string>(oid, (h) => h.Di_Note);

var val = kit.findFieldValues((SQLClip c, HHDutyItem h) => {
    return c.where(()=> h.HH_DutyItemOID, oid.ToString())
            .select(() => h.Di_Note);
    });