Example #1
0
        /// <summary>
        /// Vincula os dados adicionais.
        /// </summary>
        /// <param name="record"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public virtual IEnumerable <string> Bind(Query.IRecord record, Query.BindStrategyMode mode)
        {
            IEnumerable <string> fields = new string[0];

            if (_entityLoader != null)
            {
                if (_entityLoader.FindNameProperties != null)
                {
                    fields = fields.Concat(_entityLoader.FindNameProperties);
                }
                if (!string.IsNullOrEmpty(_entityLoader.DescriptionPropertyName))
                {
                    fields = fields.Concat(new string[] {
                        _entityLoader.DescriptionPropertyName
                    });
                }
                if (!string.IsNullOrEmpty(_entityLoader.UidPropertyName))
                {
                    fields = fields.Concat(new string[] {
                        _entityLoader.UidPropertyName
                    });
                }
                if (typeof(Data.BaseTraceableModel).IsAssignableFrom(_entityLoader.DataModelType))
                {
                    fields = fields.Concat(new string[] {
                        "ActivatedDate",
                        "ExpiredDate"
                    });
                }
            }
            foreach (var field in fields)
            {
                if (record.Descriptor.Contains(field))
                {
                    var index = record.Descriptor.GetFieldPosition(field);
                    if (index >= 0)
                    {
                        Update(field, record.GetValue(index));
                    }
                }
            }
            return(new string[0]);
        }
        /// <summary>
        /// Recupera as informações dos valores de uma lista de propriedades.
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="entityDescriptor"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        private IEnumerable <object> Merge(string[] properties, IEntityDescriptor entityDescriptor, Query.IRecord record)
        {
            var entityDescriptorStateble = entityDescriptor as IEntityDescriptorStateble;

            foreach (var p in properties)
            {
                var index = record.Descriptor.GetFieldPosition(p);
                if (index >= 0)
                {
                    yield return(record.GetValue(record.Descriptor.GetFieldPosition(p)));
                }
                else
                {
                    if (entityDescriptorStateble != null && entityDescriptorStateble.Contains(p))
                    {
                        yield return(entityDescriptorStateble[p]);
                    }
                    else
                    {
                        yield return(null);
                    }
                }
            }
        }
Example #3
0
            /// <summary>
            /// Recupera a chave simples que representa o registro.
            /// </summary>
            /// <param name="record">Instancia do registro.</param>
            /// <returns></returns>
            public string GetSimpleKey(Query.IRecord record)
            {
                record.Require("record").NotNull();
                record.Descriptor.Require("record.Descriptor").NotNull();
                var values = new string[_fieldNames.Length];

                for (var i = 0; i < values.Length; i++)
                {
                    var indexOf = 0;
                    for (; indexOf < record.Descriptor.Count; indexOf++)
                    {
                        if (StringComparer.InvariantCultureIgnoreCase.Equals(record.Descriptor[indexOf].Name, _fieldNames[i]))
                        {
                            var value = record.GetValue(indexOf);
                            if (value != null)
                            {
                                values[i] = value.ToString();
                            }
                            break;
                        }
                    }
                }
                return(string.Join("|", values));
            }