public static string DisplayShortNameFor <TModel, TValue>(this global::System.Web.Mvc.HtmlHelper <global::System.Collections.Generic.IEnumerable <TModel> > t, global::System.Linq.Expressions.Expression <global::System.Func <TModel, TValue> > exp)
        {
            CustomAttributeNamedArgument?DisplayName = null;
            var prop = exp.Body as MemberExpression;

            if (prop != null)
            {
                var DisplayAttrib = (from c in prop.Member.GetCustomAttributesData()
                                     where c.AttributeType == typeof(DisplayAttribute)
                                     select c).FirstOrDefault();
                if (DisplayAttrib != null)
                {
                    DisplayName = DisplayAttrib.NamedArguments.Where(d => d.MemberName == "ShortName").FirstOrDefault();
                }
            }
            return(DisplayName.HasValue ? DisplayName.Value.TypedValue.Value.ToString() : "");
        }
 public static void CreateMyComponent_0 <T>(global::Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder, int seq, int __seq0, T __arg0, int __seq1, global::System.Action <T> __arg1, int __seq2, global::System.Linq.Expressions.Expression <global::System.Func <T> > __arg2)
 {
     builder.OpenComponent <global::Test.MyComponent <T> >(seq);
     builder.AddAttribute(__seq0, "SomeParam", __arg0);
     builder.AddAttribute(__seq1, "SomeParamChanged", __arg1);
     builder.AddAttribute(__seq2, "SomeParamExpression", __arg2);
     builder.CloseComponent();
 }
 public static void CreateRadzenNumeric_10 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, System.Object __arg0, int __seq1, global::System.String __arg1, int __seq2, TValue __arg2, int __seq3, global::Microsoft.AspNetCore.Components.EventCallback <TValue> __arg3, int __seq4, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg4)
 {
     __builder.OpenComponent <global::Radzen.Blazor.RadzenNumeric <TValue> >(seq);
     __builder.AddAttribute(__seq0, "style", __arg0);
     __builder.AddAttribute(__seq1, "Name", __arg1);
     __builder.AddAttribute(__seq2, "Value", __arg2);
     __builder.AddAttribute(__seq3, "ValueChanged", __arg3);
     __builder.AddAttribute(__seq4, "ValueExpression", __arg4);
     __builder.CloseComponent();
 }
 partial void Engineers_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Engineer, bool> > filter);
Beispiel #5
0
 public static void CreateInputDate_1 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, System.Object __arg0, int __seq1, System.Object __arg1, int __seq2, System.Object __arg2, int __seq3, TValue __arg3, int __seq4, global::Microsoft.AspNetCore.Components.EventCallback <TValue> __arg4, int __seq5, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg5)
 {
     __builder.OpenComponent <global::Microsoft.AspNetCore.Components.Forms.InputDate <TValue> >(seq);
     __builder.AddAttribute(__seq0, "Id", __arg0);
     __builder.AddAttribute(__seq1, "name", __arg1);
     __builder.AddAttribute(__seq2, "Class", __arg2);
     __builder.AddAttribute(__seq3, "Value", __arg3);
     __builder.AddAttribute(__seq4, "ValueChanged", __arg4);
     __builder.AddAttribute(__seq5, "ValueExpression", __arg5);
     __builder.CloseComponent();
 }
 partial void IssueStatusSet_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.IssueStatus, bool> > filter);
 private static global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.IssueStatus, bool> > __IssueStatusSet_Filter(global::LightSwitchApplication.ApplicationDataService d)
 {
     global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.IssueStatus, bool> > filter = null;
     d.IssueStatusSet_Filter(ref filter);
     return(filter);
 }
Beispiel #8
0
 public static void CreateCustomInputSelect_1 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, System.Object __arg0, int __seq1, TValue __arg1, int __seq2, global::Microsoft.AspNetCore.Components.EventCallback <TValue> __arg2, int __seq3, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg3, int __seq4, global::Microsoft.AspNetCore.Components.RenderFragment __arg4)
 {
     __builder.OpenComponent <global::Moyk.Components.CustomInputSelect <TValue> >(seq);
     __builder.AddAttribute(__seq0, "class", __arg0);
     __builder.AddAttribute(__seq1, "Value", __arg1);
     __builder.AddAttribute(__seq2, "ValueChanged", __arg2);
     __builder.AddAttribute(__seq3, "ValueExpression", __arg3);
     __builder.AddAttribute(__seq4, "ChildContent", __arg4);
     __builder.CloseComponent();
 }
Beispiel #9
0
 partial void OrdenMants_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.OrdenMant, bool> > filter);
Beispiel #10
0
 partial void Account_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.AccountItem, bool> > filter);
Beispiel #11
0
 partial void InvoiceDetails_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.InvoiceDetail, bool> > filter);
Beispiel #12
0
 private static global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.EventItem, bool> > __c_Event_Filter(global::LightSwitchApplication.LightAppDataService d)
 {
     global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.EventItem, bool> > filter = null;
     d.c_Event_Filter(ref filter);
     return(filter);
 }
Beispiel #13
0
 partial void EventScores_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.EventScore, bool> > filter);
Beispiel #14
0
 partial void PvPInstances_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.PvPInstance, bool> > filter);
 public static void CreateInputMarkdown_5 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.String __arg0, int __seq1, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg1, int __seq2, global::System.String __arg2, int __seq3, global::Microsoft.AspNetCore.Components.EventCallback <global::System.String> __arg3, int __seq4, global::System.Linq.Expressions.Expression <global::System.Func <global::System.String> > __arg4)
 {
     __builder.OpenComponent <global::Movies_Blazor.Client.Shared.InputMarkdown <TValue> >(seq);
     __builder.AddAttribute(__seq0, "Label", __arg0);
     __builder.AddAttribute(__seq1, "For", __arg1);
     __builder.AddAttribute(__seq2, "Value", __arg2);
     __builder.AddAttribute(__seq3, "ValueChanged", __arg3);
     __builder.AddAttribute(__seq4, "ValueExpression", __arg4);
     __builder.CloseComponent();
 }
Beispiel #16
0
 partial void Tecnicoes_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Tecnico, bool> > filter);
        public override ICriterion VisitFieldPredicate(FieldPredicateExpression node)
        {
            var fieldName      = node.SelectorExpression.FieldName;
            var valueKey       = node.SelectorExpression.ValueKey;
            var fieldValue     = node.ValueExpression.Value;
            var fieldValueType = fieldValue != null?fieldValue.GetType() : typeof(string);

            switch (fieldName.ToLowerInvariant())
            {
            case "utccreated":
                var dateValue = (DateTimeOffset)fieldValue;
                if (dateValue == default(DateTimeOffset))
                {
                    break;
                }
                _requiresOuterNodeJoin = true;
                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.LessThanOrEqual:
                    return(Restrictions.Le(Projections.Property(() => outerNode.DateCreated), dateValue));
                }
                break;

            case "id":
                Guid idValue = GetIdValue(node);

                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.Equal:
                    _discoveredRequiredNodeIds.Add(idValue);
                    return(Restrictions.Eq(Projections.Property(() => version.Node.Id), idValue));

                case ValuePredicateType.NotEqual:
                    _negatingNodeIdsExist = true;
                    return(!Restrictions.Eq(Projections.Property(() => version.Node.Id), idValue));

                default:
                    throw new InvalidOperationException(
                              "Cannot query an item by id by any other operator than == or !=");
                }

            case "system-internal-selected-template":
                //TODO Pending property editors getting involved in query modification prior to being passed to hive provider,
                //manually check for queries against a template here
                if (valueKey == "TemplateId" && fieldValue != null)
                {
                    var tryParseResult = HiveId.TryParse(fieldValue.ToString());
                    if (!tryParseResult.Success || tryParseResult.Result.ProviderGroupRoot == null || tryParseResult.Result.ProviderId == null ||
                        (tryParseResult.Result.ProviderGroupRoot.AbsoluteUri != "storage://" && tryParseResult.Result.ProviderId != "templates"))
                    {
                        var normalisedFieldValue = "/" + fieldValue.ToString().TrimStart("/").TrimEnd(".") + ".";
                        // Need to convert the value into the serialized form that a HiveId would use
                        var newValue = new HiveId("storage", "templates", new HiveIdValue(normalisedFieldValue)).ToString(HiveIdFormatStyle.UriSafe);
                        fieldValue = newValue;
                    }
                    else
                    {
                        fieldValue = tryParseResult.Result.ToString(HiveIdFormatStyle.UriSafe);
                    }
                }
                break;
            }

            // First look up the types of the main field
            AttributeDefinition defAlias  = null;
            AttributeType       typeAlias = null;
            var attributeType             = _activeSession.NhSession.QueryOver <AttributeDefinition>(() => defAlias)
                                            .JoinAlias(() => defAlias.AttributeType, () => typeAlias)
                                            .Where(() => defAlias.Alias == fieldName)
                                            .Select(x => typeAlias.PersistenceTypeProvider)
                                            .List <string>();

            foreach (var type in attributeType)
            {
                var typeName = type;
                if (_typesAlreadyEstablished.Contains(typeName))
                {
                    continue;
                }
                try
                {
                    _typesAlreadyEstablished.Add(typeName);
                    var persisterType = Type.GetType(typeName, false);
                    if (persisterType != null)
                    {
                        var persisterInstance = Activator.CreateInstance(persisterType) as IAttributeSerializationDefinition;
                        if (persisterInstance != null && !_typesToQuery.Contains(persisterInstance.DataSerializationType))
                        {
                            _typesToQuery.Add(persisterInstance.DataSerializationType);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error <NhCriteriaVisitor>("Error while trying to decide which value-tables to join & query", ex);
                    throw;
                }
            }

            // U5-789
            // Workaround pending a better check of what data is actually saved
            // An issue arose because previous data had been saved in long-string,
            // but the datatype changed to be just string, therefore only string was
            // being queried despite all the data residing still in long-string
            if (_typesToQuery.Contains(DataSerializationTypes.String) && !_typesToQuery.Contains(DataSerializationTypes.LongString))
            {
                _typesToQuery.Add(DataSerializationTypes.LongString);
            }

            //NodeVersion aliasNodeVersion = null;
            //Attribute aliasAttribute = null;
            //AttributeDefinition aliasAttributeDefinition = null;
            //AttributeStringValue aliasStringValue = null;
            //AttributeLongStringValue aliasLongStringValue = null;
            //AttributeIntegerValue aliasIntegerValue = null;
            //AttributeDecimalValue aliasDecimalValue = null;
            //NodeRelation aliasNodeRelation = null;
            //AttributeDateValue aliasDateValue = null;

            //QueryOver<NodeVersion, AttributeDefinition> queryExtender = QueryOver.Of<NodeVersion>(() => aliasNodeVersion)
            //    .JoinQueryOver<Attribute>(() => aliasNodeVersion.Attributes, () => aliasAttribute)
            //    .JoinQueryOver<AttributeDefinition>(() => aliasAttribute.AttributeDefinition, () => aliasAttributeDefinition);

            int numberOfMatchesEvaluated         = 0;
            AbstractCriterion restrictionBuilder = null;

            foreach (var dataSerializationTypese in _typesToQuery.Distinct())
            {
                AbstractCriterion restriction = null;
                global::System.Linq.Expressions.Expression <Func <object> > propertyExpression = null;
                global::System.Linq.Expressions.Expression <Func <object> > subkeyExpression   = null;
                List <ValuePredicateType> validClauseTypes = null;
                var useLikeMatchForStrings = false;
                switch (dataSerializationTypese)
                {
                case DataSerializationTypes.SmallInt:
                case DataSerializationTypes.LargeInt:
                case DataSerializationTypes.Boolean:
                    propertyExpression = () => integerVal.Value;
                    subkeyExpression   = () => integerVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual
                    };
                    break;

                case DataSerializationTypes.Decimal:
                    propertyExpression = () => decimalVal.Value;
                    subkeyExpression   = () => decimalVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual
                    };
                    break;

                case DataSerializationTypes.String:
                    propertyExpression = () => stringVal.Value;
                    subkeyExpression   = () => stringVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Contains,
                        ValuePredicateType.StartsWith,
                        ValuePredicateType.EndsWith,
                        ValuePredicateType.MatchesWildcard
                    };
                    break;

                case DataSerializationTypes.LongString:
                    propertyExpression     = () => longStrVal.Value;
                    subkeyExpression       = () => longStrVal.ValueKey;
                    useLikeMatchForStrings = true;
                    validClauseTypes       = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Contains,
                        ValuePredicateType.StartsWith,
                        ValuePredicateType.EndsWith,
                        ValuePredicateType.MatchesWildcard
                    };
                    break;

                case DataSerializationTypes.Date:
                    propertyExpression = () => dateVal.Value;
                    subkeyExpression   = () => dateVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Empty
                    };
                    break;
                }

                if (!validClauseTypes.Contains(node.ValueExpression.ClauseType))
                {
                    throw new InvalidOperationException("A field of type {0} cannot be queried with operator {1}".InvariantFormat(dataSerializationTypese.ToString(), node.ValueExpression.ClauseType.ToString()));
                }

                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.Equal:
                    restriction = GetRestrictionEq(fieldValue, useLikeMatchForStrings, propertyExpression, subkeyExpression, valueKey);
                    break;

                case ValuePredicateType.NotEqual:
                    restriction = !GetRestrictionEq(fieldValue, useLikeMatchForStrings, propertyExpression);
                    break;

                case ValuePredicateType.LessThan:
                    restriction = GetRestrictionLt(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.LessThanOrEqual:
                    restriction = GetRestrictionLtEq(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.GreaterThan:
                    restriction = GetRestrictionGt(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.GreaterThanOrEqual:
                    restriction = GetRestrictionGtEq(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.Contains:
                    restriction = GetRestrictionContains(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.StartsWith:
                    restriction = GetRestrictionStarts(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.EndsWith:
                    restriction = GetRestrictionEnds(fieldValue, propertyExpression);
                    break;
                }

                if (restriction != null)
                {
                    if (numberOfMatchesEvaluated == 0)
                    {
                        restrictionBuilder = restriction;
                        numberOfMatchesEvaluated++;
                    }
                    else
                    {
                        restrictionBuilder = Restrictions.Or(restriction, restrictionBuilder);
                    }
                }
            }

            var fieldNameRestriction = Restrictions.Eq(Projections.Property(() => def.Alias), fieldName);

            if (restrictionBuilder != null)
            {
                restrictionBuilder = Restrictions.And(restrictionBuilder, fieldNameRestriction);
            }
            else
            {
                restrictionBuilder = fieldNameRestriction;
            }

            return(restrictionBuilder);
        }
Beispiel #18
0
 private static global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Tecnico, bool> > __Tecnicoes_Filter(global::LightSwitchApplication.ApplicationDataService d)
 {
     global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Tecnico, bool> > filter = null;
     d.Tecnicoes_Filter(ref filter);
     return(filter);
 }
 partial void Skills_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Skill, bool> > filter);
Beispiel #20
0
 partial void Componentes_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Componente, bool> > filter);
 private static global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.EngineerSkill, bool> > __EngineerSkills_Filter(global::LightSwitchApplication.ApplicationDataService d)
 {
     global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.EngineerSkill, bool> > filter = null;
     d.EngineerSkills_Filter(ref filter);
     return(filter);
 }
Beispiel #22
0
 partial void Projects_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.Project, bool> > filter);
Beispiel #23
0
 public static void CreateRadzenDatePicker_3 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.String __arg0, int __seq1, System.Object __arg1, int __seq2, global::System.String __arg2, int __seq3, global::Microsoft.AspNetCore.Components.EventCallback <global::System.DateTime?> __arg3, int __seq4, global::System.Object __arg4, int __seq5, global::Microsoft.AspNetCore.Components.EventCallback <TValue> __arg5, int __seq6, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg6)
 {
     __builder.OpenComponent <global::Radzen.Blazor.RadzenDatePicker <TValue> >(seq);
     __builder.AddAttribute(__seq0, "DateFormat", __arg0);
     __builder.AddAttribute(__seq1, "style", __arg1);
     __builder.AddAttribute(__seq2, "Name", __arg2);
     __builder.AddAttribute(__seq3, "Change", __arg3);
     __builder.AddAttribute(__seq4, "Value", __arg4);
     __builder.AddAttribute(__seq5, "ValueChanged", __arg5);
     __builder.AddAttribute(__seq6, "ValueExpression", __arg6);
     __builder.CloseComponent();
 }
Beispiel #24
0
 partial void ExpenseItems_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.ExpenseItem, bool> > filter);
Beispiel #25
0
 public static void CreateMatDatePicker_3 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Boolean __arg0, int __seq1, global::System.Boolean __arg1, int __seq2, global::System.String __arg2, int __seq3, TValue __arg3, int __seq4, global::Microsoft.AspNetCore.Components.EventCallback <TValue> __arg4, int __seq5, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg5)
 {
     __builder.OpenComponent <global::MatBlazor.MatDatePicker <TValue> >(seq);
     __builder.AddAttribute(__seq0, "Required", __arg0);
     __builder.AddAttribute(__seq1, "AllowInput", __arg1);
     __builder.AddAttribute(__seq2, "Format", __arg2);
     __builder.AddAttribute(__seq3, "Value", __arg3);
     __builder.AddAttribute(__seq4, "ValueChanged", __arg4);
     __builder.AddAttribute(__seq5, "ValueExpression", __arg5);
     __builder.CloseComponent();
 }
        public override FieldFilterResult VisitFieldPredicate(FieldPredicateExpression node)
        {
            var fieldName      = node.SelectorExpression.FieldName;
            var valueKey       = node.SelectorExpression.ValueKey;
            var fieldValue     = node.ValueExpression.Value;
            var fieldValueType = fieldValue != null?fieldValue.GetType() : typeof(string);

            var toReturn = new FieldFilterResult();

            RdbmsModel.Attribute att            = null;
            Node outerNode                      = null;
            AttributeStringValue     stringVal  = null;
            AttributeLongStringValue longStrVal = null;
            AttributeIntegerValue    integerVal = null;
            AttributeDecimalValue    decimalVal = null;
            AttributeDateValue       dateVal    = null;
            AttributeDefinition      def        = null;

            // First check for special cases, typically stuff that can be queried
            // that isn't necessarily a value in any of the Attribute*Value tables
            switch (fieldName.ToLowerInvariant())
            {
            case "utccreated":
                DateTimeOffset createdDtoValue = ParseDateTimeOffset(fieldValue);
                if (createdDtoValue == default(DateTime))
                {
                    break;
                }

                toReturn.NhCriterion = CreateRestriction(node.ValueExpression.ClauseType,
                                                         () => outerNode.DateCreated, createdDtoValue);

                if (toReturn.NhCriterion != null)
                {
                    toReturn.Joins.Add(new Join(() => agg.Node, () => outerNode, JoinType.InnerJoin));
                }

                break;

            case "utcmodified":
                DateTimeOffset modifiedDtoValue = ParseDateTimeOffset(fieldValue);
                if (modifiedDtoValue == default(DateTime))
                {
                    break;
                }

                toReturn.NhCriterion = CreateRestriction(node.ValueExpression.ClauseType,
                                                         () => agg.StatusDate, modifiedDtoValue);

                break;

            case "id":
                Guid idValue = GetIdValue(node);

                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.Equal:
                    toReturn.NhCriterion = Restrictions.Eq(Projections.Property(() => agg.Node.Id), idValue);
                    break;

                case ValuePredicateType.NotEqual:
                    toReturn.NhCriterion = !Restrictions.Eq(Projections.Property(() => agg.Node.Id), idValue);
                    break;

                default:
                    throw new InvalidOperationException("Cannot query an item by id by any other operator than == or !=");
                }
                break;

            case "system-internal-selected-template":
                //TODO Pending property editors getting involved in query modification prior to being passed to hive provider,
                //manually check for queries against a template here
                if (valueKey == "TemplateId" && fieldValue != null)
                {
                    var tryParseResult = HiveId.TryParse(fieldValue.ToString());
                    if (!tryParseResult.Success || tryParseResult.Result.ProviderGroupRoot == null || tryParseResult.Result.ProviderId == null ||
                        (tryParseResult.Result.ProviderGroupRoot.AbsoluteUri != "storage://" && tryParseResult.Result.ProviderId != "templates"))
                    {
                        var normalisedFieldValue = "/" + fieldValue.ToString().TrimStart("/").TrimEnd(".") + ".";
                        // Need to convert the value into the serialized form that a HiveId would use
                        var newValue = new HiveId("storage", "templates", new HiveIdValue(normalisedFieldValue)).ToString(HiveIdFormatStyle.UriSafe);
                        fieldValue = newValue;
                    }
                    else
                    {
                        fieldValue = tryParseResult.Result.ToString(HiveIdFormatStyle.UriSafe);
                    }
                }
                break;
            }

            if (toReturn.NhCriterion != null)
            {
                // The special-case handling above has already set the criterion,
                // so we don't have to evaluate field values in this pass and can return
                return(toReturn);
            }

            // Establish which Attribute*Value tables to query
            // First look up the types of the main field
            AttributeDefinition defAlias  = null;
            AttributeType       typeAlias = null;
            var attributeType             = _activeSession.NhSession.QueryOver <AttributeDefinition>(() => defAlias)
                                            .JoinAlias(() => defAlias.AttributeType, () => typeAlias)
                                            .Where(() => defAlias.Alias == fieldName)
                                            .Select(Projections.Distinct(Projections.Property(() => typeAlias.PersistenceTypeProvider)))
                                            .Cacheable()
                                            .List <string>();

            foreach (var type in attributeType)
            {
                var typeName = type;

                // Ensure we don't do unneccessary calls to Activator.CreateInstance,
                // (_typesAlreadyEstablished lives for the lifetime of the visitor)
                // but still make sure we populate the toReturn.ValueTypesToQuery for this
                // visit to a field predicate
                if (TypesAlreadyDiscovered.ContainsKey(typeName))
                {
                    var dst = TypesAlreadyDiscovered[typeName];
                    if (toReturn.ValueTypesToQuery.Contains(dst))
                    {
                        continue;
                    }
                    toReturn.ValueTypesToQuery.Add(dst);
                }
                try
                {
                    var persisterType = Type.GetType(typeName, false);
                    if (persisterType != null)
                    {
                        var persisterInstance = Activator.CreateInstance(persisterType) as IAttributeSerializationDefinition;
                        if (persisterInstance != null && !toReturn.ValueTypesToQuery.Contains(persisterInstance.DataSerializationType))
                        {
                            toReturn.ValueTypesToQuery.Add(persisterInstance.DataSerializationType);
                            TypesAlreadyDiscovered.TryAdd(typeName, persisterInstance.DataSerializationType);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error <NhCriteriaVisitor>("Error while trying to decide which value-tables to join & query", ex);
                    throw;
                }
            }

            // U5-789
            // Workaround pending a better check of what data is actually saved
            // An issue arose because previous data had been saved in long-string,
            // but the datatype changed to be just string, therefore only string was
            // being queried despite all the data residing still in long-string
            if (toReturn.ValueTypesToQuery.Contains(DataSerializationTypes.String) && !toReturn.ValueTypesToQuery.Contains(DataSerializationTypes.LongString))
            {
                toReturn.ValueTypesToQuery.Add(DataSerializationTypes.LongString);
            }

            // Now go through the types that we've found, and set up the expressions for the criteria
            int numberOfMatchesEvaluated         = 0;
            AbstractCriterion restrictionBuilder = null;

            foreach (var dataSerializationTypese in toReturn.ValueTypesToQuery.Distinct())
            {
                AbstractCriterion restriction = null;
                global::System.Linq.Expressions.Expression <Func <object> > propertyExpression = null;
                global::System.Linq.Expressions.Expression <Func <object> > subkeyExpression   = null;
                List <ValuePredicateType> validClauseTypes = null;
                var useLikeMatchForStrings = false;
                switch (dataSerializationTypese)
                {
                case DataSerializationTypes.SmallInt:
                case DataSerializationTypes.LargeInt:
                case DataSerializationTypes.Boolean:
                    propertyExpression = () => integerVal.Value;
                    subkeyExpression   = () => integerVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual
                    };
                    break;

                case DataSerializationTypes.Decimal:
                    propertyExpression = () => decimalVal.Value;
                    subkeyExpression   = () => decimalVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual
                    };
                    break;

                case DataSerializationTypes.String:
                    propertyExpression = () => stringVal.Value;
                    subkeyExpression   = () => stringVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Contains,
                        ValuePredicateType.StartsWith,
                        ValuePredicateType.EndsWith,
                        ValuePredicateType.MatchesWildcard
                    };
                    break;

                case DataSerializationTypes.LongString:
                    propertyExpression     = () => longStrVal.Value;
                    subkeyExpression       = () => longStrVal.ValueKey;
                    useLikeMatchForStrings = true;
                    validClauseTypes       = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Contains,
                        ValuePredicateType.StartsWith,
                        ValuePredicateType.EndsWith,
                        ValuePredicateType.MatchesWildcard
                    };
                    break;

                case DataSerializationTypes.Date:
                    propertyExpression = () => dateVal.Value;
                    subkeyExpression   = () => dateVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Empty
                    };
                    break;
                }

                if (!validClauseTypes.Contains(node.ValueExpression.ClauseType))
                {
                    throw new InvalidOperationException("A field of type {0} cannot be queried with operator {1}".InvariantFormat(dataSerializationTypese.ToString(), node.ValueExpression.ClauseType.ToString()));
                }

                // Based on the clause type, generate an NH criterion
                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.Equal:
                    restriction = GetRestrictionEq(fieldValue, useLikeMatchForStrings, propertyExpression, subkeyExpression, valueKey);
                    break;

                case ValuePredicateType.NotEqual:
                    restriction = !GetRestrictionEq(fieldValue, useLikeMatchForStrings, propertyExpression);
                    break;

                case ValuePredicateType.LessThan:
                    restriction = GetRestrictionLt(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.LessThanOrEqual:
                    restriction = GetRestrictionLtEq(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.GreaterThan:
                    restriction = GetRestrictionGt(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.GreaterThanOrEqual:
                    restriction = GetRestrictionGtEq(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.Contains:
                    restriction = GetRestrictionContains(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.StartsWith:
                    restriction = GetRestrictionStarts(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.EndsWith:
                    restriction = GetRestrictionEnds(fieldValue, propertyExpression);
                    break;
                }

                // We might be dealing with multiple restrictions even for one field (e.g. if it's been stored once in String table, and another time in LongString)
                if (restriction != null)
                {
                    if (numberOfMatchesEvaluated == 0)
                    {
                        restrictionBuilder = restriction;
                        numberOfMatchesEvaluated++;
                    }
                    else
                    {
                        // If we're doing a second or later evaluation, turn the restriction into an Or to combine them all
                        restrictionBuilder = Restrictions.Or(restriction, restrictionBuilder);
                    }
                }
            }

            // Add the field name restriction
            var fieldNameRestriction = Restrictions.Eq(Projections.Property(() => def.Alias), fieldName);

            if (restrictionBuilder != null)
            {
                restrictionBuilder = Restrictions.And(restrictionBuilder, fieldNameRestriction);
            }
            else
            {
                restrictionBuilder = fieldNameRestriction;
            }

            // Build the query which will use the restrictions we've just generated
            var query = QueryOver.Of(() => agg);

            // Set up the basic joins (not that we're adding these to a Joins collection on our own type, not just doing
            // them on an NH query, so that we can optimise or merge the joins once the entire expression tree is evaluated
            // for example inside VisitBinary)
            toReturn.Joins.Add(new Join(() => agg.NodeVersion, () => version, JoinType.InnerJoin));
            toReturn.Joins.Add(new Join(() => version.Attributes, () => att, JoinType.InnerJoin));
            toReturn.Joins.Add(new Join(() => att.AttributeDefinition, () => def, JoinType.InnerJoin));

            // Set up the joins for the value tables - only add joins for the tables that we know we want to actually query based on
            // what VisitField might have encountered and added to toReturn.ValueTypesToQuery
            foreach (var dataSerializationTypese in toReturn.ValueTypesToQuery.Distinct())
            {
                Expression <Func <object> > path  = null;
                Expression <Func <object> > alias = null;
                switch (dataSerializationTypese)
                {
                case DataSerializationTypes.SmallInt:
                case DataSerializationTypes.LargeInt:
                case DataSerializationTypes.Boolean:
                    path  = () => att.AttributeIntegerValues;
                    alias = () => integerVal;
                    break;

                case DataSerializationTypes.Decimal:
                    path  = () => att.AttributeDecimalValues;
                    alias = () => decimalVal;
                    break;

                case DataSerializationTypes.String:
                    path  = () => att.AttributeStringValues;
                    alias = () => stringVal;
                    break;

                case DataSerializationTypes.LongString:
                    path  = () => att.AttributeLongStringValues;
                    alias = () => longStrVal;
                    break;

                case DataSerializationTypes.Date:
                    path  = () => att.AttributeDateValues;
                    alias = () => dateVal;
                    break;
                }
                toReturn.Joins.Add(new Join(path, alias));
            }

            toReturn.Subquery = query
                                .Where(restrictionBuilder)
                                .Select(x => x.NodeVersion.Id);

            toReturn.NhCriterion = restrictionBuilder;
            return(toReturn);
        }
 public static void CreateRadzenDropDown_2 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Collections.IEnumerable __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.String __arg2, int __seq3, global::System.String __arg3, int __seq4, System.Object __arg4, int __seq5, global::System.String __arg5, int __seq6, global::System.Object __arg6, int __seq7, global::Microsoft.AspNetCore.Components.EventCallback <TValue> __arg7, int __seq8, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg8)
 {
     __builder.OpenComponent <global::Radzen.Blazor.RadzenDropDown <TValue> >(seq);
     __builder.AddAttribute(__seq0, "Data", __arg0);
     __builder.AddAttribute(__seq1, "TextProperty", __arg1);
     __builder.AddAttribute(__seq2, "ValueProperty", __arg2);
     __builder.AddAttribute(__seq3, "Placeholder", __arg3);
     __builder.AddAttribute(__seq4, "style", __arg4);
     __builder.AddAttribute(__seq5, "Name", __arg5);
     __builder.AddAttribute(__seq6, "Value", __arg6);
     __builder.AddAttribute(__seq7, "ValueChanged", __arg7);
     __builder.AddAttribute(__seq8, "ValueExpression", __arg8);
     __builder.CloseComponent();
 }
Beispiel #28
0
 public static void CreateInputSelectNumber_2 <T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, System.Object __arg0, int __seq1, System.Object __arg1, int __seq2, T __arg2, int __seq3, global::Microsoft.AspNetCore.Components.EventCallback <T> __arg3, int __seq4, global::System.Linq.Expressions.Expression <global::System.Func <T> > __arg4, int __seq5, global::Microsoft.AspNetCore.Components.RenderFragment __arg5)
 {
     __builder.OpenComponent <global::DemoBlazor.Utilities.InputSelectNumber <T> >(seq);
     __builder.AddAttribute(__seq0, "Class", __arg0);
     __builder.AddAttribute(__seq1, "Id", __arg1);
     __builder.AddAttribute(__seq2, "Value", __arg2);
     __builder.AddAttribute(__seq3, "ValueChanged", __arg3);
     __builder.AddAttribute(__seq4, "ValueExpression", __arg4);
     __builder.AddAttribute(__seq5, "ChildContent", __arg5);
     __builder.CloseComponent();
 }
 public static void CreateValidationMessage_0 <TValue>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Linq.Expressions.Expression <global::System.Func <TValue> > __arg0)
 {
     __builder.OpenComponent <global::Microsoft.AspNetCore.Components.Forms.ValidationMessage <TValue> >(seq);
     __builder.AddAttribute(__seq0, "For", __arg0);
     __builder.CloseComponent();
 }
Beispiel #30
0
 partial void Subscriber_Filter(ref global::System.Linq.Expressions.Expression <global::System.Func <global::LightSwitchApplication.SubscriberItem, bool> > filter);