Exemplo n.º 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);
 }
Exemplo n.º 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)};
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
        public UpdateStatementBuilder(FromClause from)
		{
            this._from = from;
		}
Exemplo n.º 5
0
        public InsertStatementBuilder(FromClause from)
		{
            this.From = from;
		}
 public AlterTableStatementBuilder(FromClause from, bool defaultFirst)
 {
     this._from = from;
     this.DefaultFirst = defaultFirst;
 }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 8
0
 public SelectStatementBuilder(FromClause from, OrderBy order, Range limit)
 {
     _from = from;
     _limit = limit;
     _order = order;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }