예제 #1
0
		private string IndKeys(APGenTable table, APGenIndex index)
		{
			string ix_keys = "";
			foreach (APGenOrder order in index.Orders)
			{
				if (ix_keys != "") ix_keys += ",";
				ix_keys += table.Columns[order.Name].ColumnName;
				if (order.According == APSqlOrderAccording.Desc)
					ix_keys += "(-)";
			}
			return ix_keys;
		}
예제 #2
0
		private void _createIndex(APDatabase db, APGenTable table, APGenIndex index)
		{
			StringBuilder sb = new StringBuilder();

			sb.AppendFormat("create index {0} on {1} (", index.Name/* IX_name(table, index)*/, table.TableName);
			foreach (APGenOrder order in index.Orders)
			{
				sb.AppendFormat("\r\n\t{0} {1},", table.Columns[order.Name].ColumnName, order.According.ToString());
			}
			sb.Length--;
			sb.Append("\r\n)");

			// create index index_name on (
			//		column_name [ASC|DESC],
			//		...
			// )

			DbCommand dbCmd = db.CreateSqlCommand(sb.ToString());
			dbCmd.ExecuteNonQuery();
		}
예제 #3
0
		private void _createUnique(APDatabase db, APGenTable table, APGenIndex index)
		{
			StringBuilder sb = new StringBuilder();

			sb.AppendFormat("alter table {0} add constraint {1} unique (", table.TableName, index.Name/* UQ_name(table, index)*/);
			foreach (APGenOrder order in index.Orders)
			{
				sb.AppendFormat("\r\n\t{0} {1},", table.Columns[order.Name].ColumnName, order.According.ToString());
			}
			sb.Length--;
			sb.Append("\r\n)");

			// alter table table_name add constraint uq_name (
			//		column_name DESC,
			//		...
			// )

			DbCommand dbCmd = db.CreateSqlCommand(sb.ToString());
			dbCmd.ExecuteNonQuery();
		}
		private void CreateDalConditionQueryOrderByIndex(CodeTypeDeclaration cns, APGenTable table, APGenIndex index, bool isView)
		{
			CodeMemberMethod method = NewMemberMethod(conditionQueryMethodName + "OrderBy" + index.Name, MemberAttributes.Public, APResource.APBusiness_ConditionQueryComment, Param(WherePhraseType, "condition"), Param(typeof(int), "maxReturnCount"));
			cns.Members.Add(method);
			CodeTypeReference listType = TypeTRef("List", table.DataType);
			method.ReturnType = listType;

			method.Statements.Add(
				Return(MethodInvoke(conditionQueryMethodName,
				ParamRef("condition"),
				PropRef(FieldRef(DBDef, table.Name), index.Name),
				ParamRef("maxReturnCount")))
				);
		}