当前位置: 首页>>代码示例>>C#>>正文


C# SelectQuery类代码示例

本文整理汇总了C#中SelectQuery的典型用法代码示例。如果您正苦于以下问题:C# SelectQuery类的具体用法?C# SelectQuery怎么用?C# SelectQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SelectQuery类属于命名空间,在下文中一共展示了SelectQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Finalize

		public override SelectQuery Finalize(SelectQuery selectQuery)
		{
			selectQuery = base.Finalize(selectQuery);

			new QueryVisitor().Visit(selectQuery.Select, element =>
			{
				if (element.ElementType == QueryElementType.SqlParameter)
				{
					((SqlParameter)element).IsQueryParameter = false;
					selectQuery.IsParameterDependent = true;
				}
			});

			switch (selectQuery.QueryType)
			{
				case QueryType.Delete :
					selectQuery = GetAlternativeDelete(selectQuery);
					selectQuery.From.Tables[0].Alias = "$";
					break;

				case QueryType.Update :
					selectQuery = GetAlternativeUpdate(selectQuery);
					break;
			}

			return selectQuery;
		}
开发者ID:donners77,项目名称:linq2db,代码行数:27,代码来源:SqlCeSqlOptimizer.cs

示例2: Finalize

		public override SelectQuery Finalize(SelectQuery selectQuery)
		{
			CheckAliases(selectQuery, int.MaxValue);

			new QueryVisitor().VisitParentFirst(selectQuery, SearchSelectClause);

			if (selectQuery.QueryType == QueryType.InsertOrUpdate)
			{
				foreach (var key in selectQuery.Insert.Items)
					new QueryVisitor().Visit(key.Expression, SetNonQueryParameter);

				foreach (var key in selectQuery.Update.Items)
					new QueryVisitor().Visit(key.Expression, SetNonQueryParameter);

				foreach (var key in selectQuery.Update.Keys)
					new QueryVisitor().Visit(key.Expression, SetNonQueryParameter);
			}

			selectQuery = base.Finalize(selectQuery);

			switch (selectQuery.QueryType)
			{
				case QueryType.Delete : return GetAlternativeDelete(selectQuery);
				case QueryType.Update : return GetAlternativeUpdate(selectQuery);
				default               : return selectQuery;
			}
		}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:27,代码来源:FirebirdSqlOptimizer.cs

示例3: BuildSql

		protected override void BuildSql(int commandNumber, SelectQuery selectQuery, StringBuilder sb, int indent, bool skipAlias)
		{
			SelectQuery   = selectQuery;
			StringBuilder = sb;
			Indent        = indent;
			SkipAlias     = skipAlias;

			if (_identityField != null)
			{
				indent += 2;

				AppendIndent().AppendLine("SELECT");
				AppendIndent().Append("\t");
				BuildExpression(_identityField, false, true);
				sb.AppendLine();
				AppendIndent().AppendLine("FROM");
				AppendIndent().AppendLine("\tNEW TABLE");
				AppendIndent().AppendLine("\t(");
			}

			base.BuildSql(commandNumber, selectQuery, sb, indent, skipAlias);

			if (_identityField != null)
				sb.AppendLine("\t)");
		}
开发者ID:donners77,项目名称:linq2db,代码行数:25,代码来源:DB2SqlBuilderBase.cs

示例4: RenderSelect

		private string RenderSelect(SelectQuery query, bool renderOrderBy)
		{
			query.Validate();

			StringBuilder selectBuilder = new StringBuilder();

			//Start the select statement
			Select(selectBuilder, query.Distinct);

			//Render Top clause
			if (query.Top > -1)
			{
				selectBuilder.AppendFormat("top {0} ", query.Top);
			}

			//Render select columns
			SelectColumns(selectBuilder, query.Columns);

			FromClause(selectBuilder, query.FromClause, query.TableSpace);

			Where(selectBuilder, query.WherePhrase);
			WhereClause(selectBuilder, query.WherePhrase);

			if (renderOrderBy)
			{
				OrderBy(selectBuilder, query.OrderByTerms);
				OrderByTerms(selectBuilder, query.OrderByTerms);
			}

			return selectBuilder.ToString();
		}
开发者ID:TargetProcess,项目名称:Tp.HelpDesk,代码行数:31,代码来源:SqlServerRenderer.cs

示例5: RenderSelect

		private string RenderSelect(SelectQuery query, bool forRowCount, int offset, int limitRows)
		{
			query.Validate();

			StringBuilder selectBuilder = new StringBuilder();

			//Start the select statement
			Select(selectBuilder, query.Distinct);

			//Render select columns
			if (forRowCount)
			{
				SelectColumn(selectBuilder, new SelectColumn("*", null, "cnt", SqlAggregationFunction.Count));
			}
			else
			{
				SelectColumns(selectBuilder, query.Columns);
			}

			FromClause(selectBuilder, query.FromClause, query.TableSpace);

			Where(selectBuilder, query.WherePhrase);
			WhereClause(selectBuilder, query.WherePhrase);

			OrderBy(selectBuilder, query.OrderByTerms);
			OrderByTerms(selectBuilder, query.OrderByTerms);

			if (limitRows > -1)
			{
				selectBuilder.AppendFormat(" limit {0}, {1}", offset, limitRows);
			}

			return selectBuilder.ToString();
		}
开发者ID:TargetProcess,项目名称:Tp.HelpDesk,代码行数:34,代码来源:MySqlRenderer.cs

示例6: Execute

			public string Execute(string itemID, string srlnCode)
			{
				string retVal = String.Empty;

				var qry = new SelectQuery();
				var srln = FromTerm.Table("GXSERIALNUMBER", "srnl");
				qry.FromClause.BaseTable =srln;
				qry.Columns.Add(new SelectColumn("GXID", srln));
				qry.WherePhrase.Terms.Add(WhereTerm.CreateCompare(
					SqlExpression.Field("GXITEMID", srln), 
					SqlExpression.Parameter("@itemID"),
					CompareOperator.Equal));
				qry.WherePhrase.Terms.Add(WhereTerm.CreateCompare(
					SqlExpression.Field("GXCODE"), 
					SqlExpression.Parameter("@srlnCode"),
					CompareOperator.Equal));

				var dataAccess = AppContext.ServiceLocator.GetService<IslDataAccessDbProvider>();
				string sqlText = slRendererFactory.GetRenderer(dataAccess.Info.DBProviderName).RenderSelect(qry);
				slQueryParameters qryParams = new slQueryParameters();

				qryParams.Add("@itemID", itemID);
				qryParams.Add("@srlnCode", srlnCode);

				object res = dataAccess.ExecuteScalar(sqlText, qryParams);
				if (res != null && res != DBNull.Value)
					retVal = Convert.ToString(res);
				
				return retVal;
			}
开发者ID:Gabsamolis,项目名称:S-N-Excel-Import,代码行数:30,代码来源:infnvAddIn.cs

示例7: BuildSql

		protected override void BuildSql(int commandNumber, SelectQuery selectQuery, StringBuilder sb, int indent, bool skipAlias)
		{
			base.BuildSql(commandNumber, selectQuery, sb, indent, skipAlias);

			sb
				.Replace("NULL IS NOT NULL", "1=0")
				.Replace("NULL IS NULL",     "1=1");
		}
开发者ID:donners77,项目名称:linq2db,代码行数:8,代码来源:InformixSqlBuilder.cs

示例8: GenerateSingleMapper

 private static Delegate GenerateSingleMapper() {
     var config = new CustomConfig();
     var selectQuery = new SelectQuery<Post>(new Mock<ISelectQueryExecutor>().Object).Fetch(p => p.Blog) as SelectQuery<Post>;
     var writer = new SelectWriter(new SqlServer2012Dialect(), config);
     var result = writer.GenerateSql(selectQuery);
     var mapper = new NonCollectionMapperGenerator(config);
     var func = mapper.GenerateNonCollectionMapper<Post>(result.FetchTree);
     return func.Item1;
 }
开发者ID:Polylytics,项目名称:dashing,代码行数:9,代码来源:NonCollectionTests.cs

示例9: Finalize

		public override SelectQuery Finalize(SelectQuery selectQuery)
		{
			selectQuery = base.Finalize(selectQuery);

			switch (selectQuery.QueryType)
			{
				case QueryType.Delete : return GetAlternativeDelete(selectQuery);
				default               : return selectQuery;
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:10,代码来源:AccessSqlOptimizer.cs

示例10: ShouldCreateAndWhereQuery

        public void ShouldCreateAndWhereQuery()
        {
            var query =
                new SelectQuery<Model.Model>().Select("Id")
                    .Where("Id", new IsNotNull<int>())
                    .AndWhere("Id", new IsNull<int>())
                    .ToString();

            query.Should().Be("SELECT [Id] FROM [Model] WHERE ([Id] IS NOT NULL AND [Id] IS NULL)");
        }
开发者ID:JonyTek,项目名称:Mini-Data,代码行数:10,代码来源:SelectQuerySpecs.cs

示例11: CommandCount

        public override int CommandCount(SelectQuery selectQuery)
        {
            if (Version == DB2Version.LUW && selectQuery.IsInsert && selectQuery.Insert.WithIdentity)
            {
                _identityField = selectQuery.Insert.Into.GetIdentityField();

                if (_identityField == null)
                    return 2;
            }

            return 1;
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:12,代码来源:DB2SqlBuilderBase.cs

示例12: CommandCount

        public override int CommandCount(SelectQuery selectQuery)
        {
            if (selectQuery.IsCreateTable)
            {
                _identityField = selectQuery.CreateTable.Table.Fields.Values.FirstOrDefault(f => f.IsIdentity);

                if (_identityField != null)
                    return 3;
            }

            return base.CommandCount(selectQuery);
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:12,代码来源:OracleSqlBuilder.cs

示例13: Finalize

		public override SelectQuery Finalize(SelectQuery selectQuery)
		{
			CheckAliases(selectQuery, int.MaxValue);

			selectQuery = base.Finalize(selectQuery);

			switch (selectQuery.QueryType)
			{
				case QueryType.Delete : return GetAlternativeDelete(selectQuery);
				case QueryType.Update : return GetAlternativeUpdate(selectQuery);
				default               : return selectQuery;
			}
		}
开发者ID:donners77,项目名称:linq2db,代码行数:13,代码来源:PostgreSQLSqlOptimizer.cs

示例14: Finalize

		public override SelectQuery Finalize(SelectQuery selectQuery)
		{
			new QueryVisitor().Visit(selectQuery.Select, SetQueryParameter);

			selectQuery = base.Finalize(selectQuery);

			switch (selectQuery.QueryType)
			{
				case QueryType.Delete : return GetAlternativeDelete(selectQuery);
				case QueryType.Update : return GetAlternativeUpdate(selectQuery);
				default               : return selectQuery;
			}
		}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:13,代码来源:DB2SqlOptimizer.cs

示例15: ProcessQuery

			protected override SelectQuery ProcessQuery(SelectQuery selectQuery)
			{
				if (selectQuery.IsInsert && selectQuery.Insert.Into.Name == "Parent")
				{
					var expr =
						new QueryVisitor().Find(selectQuery.Insert, e =>
						{
							if (e.ElementType == QueryElementType.SetExpression)
							{
								var se = (SelectQuery.SetExpression)e;
								return ((SqlField)se.Column).Name == "ParentID";
							}

							return false;
						}) as SelectQuery.SetExpression;

					if (expr != null)
					{
						var value = ConvertTo<int>.From(((IValueContainer)expr.Expression).Value);

						if (value == 555)
						{
							var tableName = "Parent1";
							var dic       = new Dictionary<IQueryElement,IQueryElement>();

							selectQuery = new QueryVisitor().Convert(selectQuery, e =>
							{
								if (e.ElementType == QueryElementType.SqlTable)
								{
									var oldTable = (SqlTable)e;

									if (oldTable.Name == "Parent")
									{
										var newTable = new SqlTable(oldTable) { Name = tableName, PhysicalName = tableName };

										foreach (var field in oldTable.Fields.Values)
											dic.Add(field, newTable.Fields[field.Name]);

										return newTable;
									}
								}

								IQueryElement ex;
								return dic.TryGetValue(e, out ex) ? ex : null;
							});
						}
					}
				}

				return selectQuery;
			}
开发者ID:donners77,项目名称:linq2db,代码行数:51,代码来源:Common.cs


注:本文中的SelectQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。