Beispiel #1
0
 internal ObjectInfo(Type t)
 {
     this.HandleType = t;
     this.CheckTypeIsModel();
     List<MemberHandler> members = this.GetMembers();
     this.KeyMembers = members.FindAll(m => m.Is.Key).ToArray();
     this.CheckKeys();
     this.SimpleMembers = this.GetSimpleMembers(members);
     this.RelationMembers = members.FindAll(m => !m.Is.SimpleField).ToArray();
     this.Members = this.GetAllMembers();
     this.From = GetObjectFromClause(t);
     this.AllowSqlLog = this.IsAllowSqlLog();
     this.HasSystemKey = this.GetHasSystemKey();
     this.HasRelation = members.Exists(delegate(MemberHandler m)
     {
         if ((!m.Is.HasOne && !m.Is.HasMany) && !m.Is.HasAndBelongsToMany)
         {
             return m.Is.BelongsTo;
         }
         return true;
     });
     this.LockVersion = members.FirstOrDefault(m => m.Is.LockVersion);
     this.HasOnePrimaryKey = this.GetHasOnePrimaryKey();
     this.SoftDeleteColumnName = this.GetSoftDeleteColumnName();
     this.DeleteToTableName = this.GetDeleteToTableName();
     this.ContextName = this.GetContextName();
     this.QueryRequiredFields = this.GetQueryRequiredFields();
     this.Cacheable = this.HandleType.HasAttribute<CacheableAttribute>(false);
     this.GetIndexes();
     SetManyToManyFrom(this, this.From.MainModelName, this.Members);
 }
Beispiel #2
0
 public CrossTable(Type handleType, FromClause from, string name, 
     string table1, string column1, string table2, string column2)
 {
     this.HandleType = handleType;
     this.From = from;
     this.Name = name;
     _columns = new List<RefColumn> {new RefColumn(table1, column1), new RefColumn(table2, column2)};
 }
 public override SelectStatementBuilder GetSelectStatementBuilder(FromClause from, Condition iwc, OrderBy oc, Range lc, bool isDistinct, bool noLazy, Type returnType, string colName)
 {
     return base.GetSelectStatementBuilder(from, iwc && _colExp, oc, lc, isDistinct, noLazy, returnType, colName);
 }
        public UpdateStatementBuilder(FromClause from)
		{
            this._from = from;
		}
        public InsertStatementBuilder(FromClause from)
		{
            this.From = from;
		}
 public AlterTableStatementBuilder(FromClause from, bool defaultFirst)
 {
     this._from = from;
     this.DefaultFirst = defaultFirst;
 }
Beispiel #7
0
 private static void SetManyToManyFrom(ObjectInfo oi, string unmappedMainTableName, IEnumerable<MemberHandler> fields)
 {
     foreach (MemberHandler member in fields)
     {
         if (member.Is.HasAndBelongsToMany)
         {
             var modelType = member.MemberType.GetGenericArguments()[0];
             var fromClause = GetObjectFromClause(modelType);
             var mainOriginTableName = fromClause.MainModelName;
             var name = GetCrossTableName(member, unmappedMainTableName, mainOriginTableName);
             var fkMainOriginTableName = mainOriginTableName + "_Id";
             var from = new FromClause(new[] { new JoinClause(name, fkMainOriginTableName, fromClause.MainTableName, "Id", CompareOpration.Equal, JoinMode.Inner) });
             var handleType = member.MemberType.GetGenericArguments()[0];
             oi.CrossTables[handleType] = new CrossTable(handleType, from, name,
                 oi.From.MainTableName, unmappedMainTableName + "_Id", fromClause.MainTableName, fkMainOriginTableName);
         }
     }
 }
 public SelectStatementBuilder(FromClause from, OrderBy order, Range limit)
 {
     _from = from;
     _limit = limit;
     _order = order;
 }
Beispiel #9
0
 public virtual SelectStatementBuilder GetSelectStatementBuilder(FromClause from, Condition iwc, OrderBy oc, Range lc, bool isDistinct, bool noLazy, Type returnType, string colName)
 {
     var sb = new SelectStatementBuilder(from ?? this.Context.Info.From, oc, lc)
                        {
                            IsDistinct = isDistinct,
                            NoLazy = noLazy
                        };
     sb.Where.Conditions = iwc;
     if (!colName.IsNullOrEmpty())
     {
         sb.Keys.Add(new KeyValuePair<string, string>(colName, null));
         return sb;
     }
     if (returnType.Name.StartsWith("<"))
     {
         this.SetSelectColumnsForDynamicLinqObject(sb, returnType);
         return sb;
     }
     this.Context.Handler.SetValuesForSelect(sb, noLazy);
     return sb;
 }
Beispiel #10
0
 public SqlStatement GetSelectStatement(FromClause from, Condition iwc, OrderBy oc, Range lc, bool isDistinct, bool noLazy, Type returnType)
 {
     return this.GetSelectStatementBuilder(from, iwc, oc, lc, isDistinct, noLazy, returnType, null).ToSqlStatement(this.Context);
 }