本文整理汇总了C#中System.Linq.Expressions.ConstantExpression类的典型用法代码示例。如果您正苦于以下问题:C# ConstantExpression类的具体用法?C# ConstantExpression怎么用?C# ConstantExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstantExpression类属于System.Linq.Expressions命名空间,在下文中一共展示了ConstantExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitConstant
protected override Expression VisitConstant(ConstantExpression c)
{
// have to do something here about type matching the types of Azure services
if (c.Type == typeof(LinqToAzureOrderedQueryable<StorageAccount>) || c.Type == typeof(LinqToAzureOrderedQueryable<CloudService>))
return Expression.Constant(_accounts);
return c;
}
开发者ID:AndrewJutton,项目名称:fluent-management,代码行数:7,代码来源:ExpressionTreeModifier.cs
示例2: Replace
internal static Expression Replace(Expression expressionToAlter,
ConstantExpression subExpressionToFind, Expression replacementExpression)
{
var visitor = new SubExpressionReplacer(subExpressionToFind, replacementExpression);
return visitor.Visit(expressionToAlter);
}
开发者ID:BrettJaner,项目名称:SimpleInjector,代码行数:7,代码来源:SubExpressionReplacer.cs
示例3: VisitConstant
protected override Expression VisitConstant(ConstantExpression constantExpression)
{
return constantExpression.Type.GetTypeInfo().IsGenericType
&& constantExpression.Type.GetGenericTypeDefinition() == typeof(EntityQueryable<>)
? VisitEntityQueryable(((IQueryable)constantExpression.Value).ElementType)
: constantExpression;
}
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:7,代码来源:EntityQueryableExpressionVisitor.cs
示例4: VisitConstant
protected override Expression VisitConstant(ConstantExpression constantExpression)
{
if (constantExpression.Value == null)
{
return base.VisitConstant(constantExpression);
}
var type = constantExpression.Value.GetType();
switch (Type.GetTypeCode(type))
{
case TypeCode.Boolean:
if (Convert.ToBoolean(constantExpression.Value))
{
this.Write(this.ParameterIndicatorPrefix);
this.Write(ParamNamePrefix);
this.Write(this.parameterValues.Count);
this.parameterValues.Add(new Tuple<Type, object>(typeof(string), "true"));
return constantExpression;
}
else
{
this.Write(this.ParameterIndicatorPrefix);
this.Write(ParamNamePrefix);
this.Write(this.parameterValues.Count);
this.parameterValues.Add(new Tuple<Type, object>(typeof(string), "false"));
return constantExpression;
}
}
return base.VisitConstant(constantExpression);
}
开发者ID:ciker,项目名称:Shaolinq,代码行数:34,代码来源:SqlServerSqlQueryFormatter.cs
示例5: VisitConstant
protected override Expression VisitConstant(ConstantExpression c)
{
if (c.Type == typeof(MethodInfo))
_methodInfo = c.Value as MethodInfo;
return base.VisitConstant(c);
}
开发者ID:rickj33,项目名称:Stact,代码行数:7,代码来源:FindMethodCallVisitor.cs
示例6: ConvertEntityRef
private string ConvertEntityRef(ConstantExpression expression)
{
FieldInfo field = expression.Value.GetType().GetFields().First();
object value = field.GetValue(expression.Value);
this.Parameters.Add(value);
return "?";
}
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:7,代码来源:Constants.cs
示例7: CreateNamedValueForConstant
protected virtual NamedValueExpression CreateNamedValueForConstant(ConstantExpression expression)
{
var name = "p" + (iParam++);
var nv = new NamedValueExpression(name, expression);
map.Add(GetKeyNameForConstantExpression(expression), new List<NamedValueExpression> { nv });
return nv;
}
开发者ID:alonsorobles,项目名称:SubSonic-3.0,代码行数:7,代码来源:Parameterizer.cs
示例8: From
public static QueryProxyReference From(ConstantExpression cex)
{
return new QueryProxyReference
{
Type = XmlMetadataInfo.FromMetadata(cex.Type)
};
}
开发者ID:xeno-by,项目名称:relinq,代码行数:7,代码来源:QueryProxyReference.cs
示例9: VisitConstant
protected override Expression VisitConstant(ConstantExpression c)
{
IQueryable q = c.Value as IQueryable;
if (q != null)
{
_query.Index = q.ElementType.Name;
}
else if (c.Value == null)
{
//sb.Append("NULL");
}
else
{
switch (Type.GetTypeCode(c.Value.GetType()))
{
case TypeCode.Boolean:
//sb.Append(((bool)c.Value) ? 1 : 0);
break;
case TypeCode.String:
// sb.Append("'");
// sb.Append(c.Value);
// sb.Append("'");
break;
case TypeCode.Object:
throw new NotSupportedException(string.Format("The constant for '{0}' is not supported", c.Value));
default:
// sb.Append(c.Value);
break;
}
}
return c;
}
开发者ID:bgertonson,项目名称:CogsDB,代码行数:32,代码来源:QueryTranslator.cs
示例10: AddQueryPart
public void AddQueryPart(UnaryExpression leftItem, ConstantExpression rightValue, ExpressionType nodeType)
{
if(leftItem.Operand is MethodCallExpression)
{
var unaryOperation = (MethodCallExpression)leftItem.Operand;
if(unaryOperation.Method.Name != "get_Item")
{
throw new InvalidOperationException("Queries based on " + leftItem.Method.Name + " are not yet supported.");
}
if(unaryOperation.Arguments[0] is ConstantExpression)
{
var attributeRef = ((ConstantExpression) unaryOperation.Arguments[0]).Value;
AddCriteriaToActiveSearchCondition(attributeRef.ToString(), rightValue.Value, GetSearchRelationType(nodeType));
}
else
{
throw new InvalidOperationException("Only constant expressions are currently supported.");
}
}
else
{
throw new InvalidOperationException("Queries based on " + leftItem.Method.Name + " are not yet supported.");
}
}
开发者ID:davidwhitney,项目名称:QuantivContrib,代码行数:27,代码来源:QuantivEntityQueryBuilder.cs
示例11: VisitConstant
protected override Expression VisitConstant(ConstantExpression constantExpression)
{
var type = constantExpression.Type;
if ((this.options & SqlExpressionComparerOptions.IgnoreConstants) != 0)
{
return constantExpression;
}
if (type.IsValueType)
{
if (constantExpression.Value != null)
{
this.hashCode ^= constantExpression.Value.GetHashCode();
}
}
else if (typeof(Expression).IsAssignableFrom(constantExpression.Type))
{
this.Visit((Expression)constantExpression.Value);
}
else if (type == typeof(string))
{
this.hashCode ^= constantExpression.Value?.GetHashCode() ?? 0;
}
return constantExpression;
}
开发者ID:crazle,项目名称:Shaolinq,代码行数:27,代码来源:SqlExpressionHasher.cs
示例12: ReplaceConstantsWithArrayIndexes
public static Expression ReplaceConstantsWithArrayIndexes(Expression node,
ConstantExpression[] constantExpressions, ParameterExpression constantsParameter)
{
var visitor = new ConstantArrayIndexizerVisitor(constantExpressions, constantsParameter);
return visitor.Visit(node);
}
开发者ID:BrettJaner,项目名称:SimpleInjector,代码行数:7,代码来源:ConstantArrayIndexizerVisitor.cs
示例13: VisitConstant
protected override Expression VisitConstant(ConstantExpression c)
{
if (c.Type == typeof(JournalItemsContext<UAutoContractJournalItem>))
return Expression.Constant(this.queryableJournalItems);
else
return c;
}
开发者ID:andreychizhov,项目名称:NestQueryableProvider,代码行数:7,代码来源:ExpressionTreeModifier.cs
示例14: VisitConstant
protected override Expression VisitConstant(ConstantExpression node)
{
if (node.Value is IQueryable)
sourceQueryable = ((IQueryable)node.Value);
return node;
}
开发者ID:jarlrasm,项目名称:ElasticLINQ,代码行数:7,代码来源:QuerySourceExpressionVisitor.cs
示例15: VisitConstant
protected override Expression VisitConstant(ConstantExpression c)
{
IQueryable q = c.Value as IQueryable;
if (q != null) {
//throw new ApplicationException("Nested expressions not supported.");
}
else if (c.Value == null) {
sb.Append("null");
}
else {
if (c.Value.GetType() == typeof(Guid)) {
sb.Append("'");
sb.Append(c.Value);
sb.Append("'");
}
else {
switch (Type.GetTypeCode(c.Value.GetType())) {
case TypeCode.DateTime:
sb.Append("'");
sb.Append(((DateTime)c.Value).ToString("o"));
sb.Append("'");
break;
case TypeCode.Object:
throw new NotSupportedException(string.Format("The constant for '{0}' is not supported SimpleDB.", c.Value));
default:
sb.Append("'");
sb.Append(c.Value);
sb.Append("'");
break;
}
}
}
return c;
}
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:34,代码来源:SimpleDBExpressionVisitor.cs
示例16: EvaluateMemberAccessProperty
private static object EvaluateMemberAccessProperty(ConstantExpression node, PropertyInfo propertyAccessor)
{
var prop = node == null ? null : node.Value;
var value = propertyAccessor.GetValue(prop, null);
return ConvertMemberAccessValue(value);
}
开发者ID:darrencauthon,项目名称:SisoDb-Provider,代码行数:7,代码来源:ExpressionEvaluator.cs
示例17: VisitConstant
protected override Expression VisitConstant(ConstantExpression node)
{
var value = node.Value as int?;
if (value.HasValue)
return Expression.Constant(value + 1, node.Type);
return base.VisitConstant(node);
}
开发者ID:Pomona,项目名称:Pomona,代码行数:7,代码来源:InterceptedQueryProviderTests.cs
示例18: WalkConstant
protected override Expression WalkConstant(ConstantExpression con)
{
var q = con.Value as IQueryable;
if (q != null)
{
output.Append("SELECT * FROM ");
output.Append(NameLookup.GetTableName(q.ElementType));
}
else if (con.Value == null)
{
output.Append("NULL");
}
else
{
switch (Type.GetTypeCode(con.Type))
{
case TypeCode.Boolean: output.Append(((bool)con.Value) ? 1 : 0); break;
case TypeCode.String: output.AppendFormat("'{0}'", con.Value); break;
case TypeCode.DateTime: output.AppendFormat("'{0:dd-MM-yyyy HH:mm:ss}'", con.Value); break;
case TypeCode.Object: throw new UnsupportedQueryException(string.Format("Can't handle '{0}' constant in expression", con));
default:
output.Append(con.Value); break;
}
}
return con;
}
开发者ID:NeilWhite,项目名称:XBMCLibrary,代码行数:27,代码来源:QueryTranslator.cs
示例19: VisitConstant
protected override System.Linq.Expressions.Expression VisitConstant(ConstantExpression c)
{
switch(Type.GetTypeCode(c.Value.GetType()))
{
case TypeCode.Boolean:
_sb.Append(((bool)c.Value) ? "Value=\"True\"" : " Value=\"False\"");
break;
case TypeCode.String:
_sb.Append(" Value=\"");
_sb.Append(c.Value);
_sb.Append("\"");
break;
case TypeCode.Object:
throw new NotSupportedException(string.Format("The constant for '{0}' is not supported", c.Value));
default:
_sb.Append(c.Value);
break;
}
//if (!string.IsNullOrEmpty(currentMember)) {
// sb.Append("</");
// sb.Append(currentMember);
// sb.Append(">");
// currentMember = string.Empty;
//}
return c;
}
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:30,代码来源:ExpressionVisitorDSFImpl.cs
示例20: VisitConstant
protected override Expression VisitConstant(ConstantExpression c)
{
if (c.Type == queryType)
return Expression.Constant(queryableContents);
return c;
}
开发者ID:prepare,项目名称:deveeldb,代码行数:7,代码来源:ExpressionTreeModifier.cs
注:本文中的System.Linq.Expressions.ConstantExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论