using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Ant.ORM { /// /// 关联表 /// public class MakeJoinTable { private static object lockHelper = new object(); private static volatile MakeJoinTable instance = null; public List RootList = new List(); private JoinOnTableNode item; private int i = 0; public MakeJoinTable() { } public static MakeJoinTable Instance { get { if (instance == null) { lock (lockHelper) { if (instance == null) { instance = new MakeJoinTable(); } } } return instance; } } #region IDictionary 成员 /// /// 左关联查询(左边是主表,右边是关联表) /// /// 主表 /// 次表 /// 关联表别名 /// public MakeJoinTable LeftJoin(string asname) { item = new JoinOnTableNode(); item.TableName = typeof(TM).Name; item.NTableName = typeof(TN).Name; item.NTableAsName = asname; item.JoinType = JoinTypes.LeftJoin; return this; } /// /// InnerJoin关联查询(左边是主表,右边是关联表) /// /// 主表 /// 次表 /// 关联表别名 /// public MakeJoinTable InnerJoin(string asname) { item = new JoinOnTableNode(); item.TableName = typeof(TM).Name; item.NTableName = typeof(TN).Name; item.NTableAsName = asname; item.JoinType = JoinTypes.Inner; return this; } /// /// 右关联查询(左边是主表,右边是关联表) /// /// 主表 /// 次表 /// 关联表别名 /// public MakeJoinTable RihtJoin(string asname) { item = new JoinOnTableNode(); item.TableName = typeof(TM).Name; item.NTableName = typeof(TN).Name; item.NTableAsName = asname; item.JoinType = JoinTypes.RightJoin; return this; } /// /// 关联表条件 /// /// 主表关联字段 /// 次表关联字段 /// public MakeJoinTable JoinOn(Enum mSql, Enum nSql) { item.JoinOn1 = mSql.ToString(); item.JoinOn2 = nSql.ToString(); RootList.Add(item); return this; } #endregion } public class JoinColumn { private string TableName; private int Num; } }