public void Add(FilterCriteria filterCriteria)
        {
            if (filterCriteria == null)
            {
                return;
            }

            if (_isFilterData)
            {
                throw new Exception("Only Filter Data can be added.");
            }

            if (_listFilterCriteria == null)
            {
                _listFilterCriteria = new FilterCriteria[] { filterCriteria }
            }
            ;
            else
            {
                _listFilterCriteria = _listFilterCriteria.Concat(new FilterCriteria[] { filterCriteria }).ToArray();
            }
        }
        public static IList <T> GetAll(FilterCriteria filterCriteria, string orderBy)
        {
            var       instanceEntity = Activator.CreateInstance <T>();
            var       properties     = instanceEntity.GetType().GetProperties();
            IList <T> listObject     = new List <T>();

            using (var conection = BaseData.DbConnection()) {
                string sqlWhere = string.Empty;
                if (filterCriteria != null)
                {
                    sqlWhere = " WHERE " + filterCriteria.ToString(instanceEntity);
                }

                string orderByCommand = string.Empty;
                if (!string.IsNullOrWhiteSpace(orderBy))
                {
                    orderByCommand = " ORDER BY " + orderBy;
                }

                SQLiteCommand sQLiteCommand = new SQLiteCommand($"SELECT * FROM {instanceEntity.GetType().Name} {sqlWhere} {orderByCommand} {COLLATE_NOCASE_VALUE} ", conection);
                decimal       decimalValue  = 0;
                //double doubleValue = 0;
                int      intValue  = 0;
                DateTime dateValue = DateTime.MinValue;
                object[] attributesObject;

                using (var read = sQLiteCommand.ExecuteReader()) {
                    while (read.Read())
                    {
                        instanceEntity = Activator.CreateInstance <T>();

                        foreach (var item in properties)
                        {
                            attributesObject = item.GetCustomAttributes(false);
                            if (attributesObject != null && attributesObject.Length > 0 && attributesObject.Any(x => x is NotMappedAttribute))
                            {
                                continue;
                            }
                            switch (item.PropertyType.Name)
                            {
                            case "String":
                                instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, Convert.ToString(read[item.Name]));
                                break;

                            case "Char":
                                instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, Convert.ToChar(read[item.Name]));
                                break;

                            case "Decimal":
                                if (read[item.Name] != null && decimal.TryParse(Convert.ToString(read[item.Name]), out decimalValue))
                                {
                                    instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, decimalValue);
                                }
                                break;

                            case "Int32":
                            case "Int64":
                                if (read[item.Name] != null && int.TryParse(Convert.ToString(read[item.Name]), out intValue))
                                {
                                    instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, intValue);
                                }
                                break;

                            case "DateTime":
                                if (read[item.Name] != null && DateTime.TryParse(Convert.ToString(read[item.Name]), out dateValue))
                                {
                                    instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, dateValue);
                                }
                                break;

                            case "Boolean":
                                if (read[item.Name] != null && int.TryParse(Convert.ToString(read[item.Name]), out intValue))
                                {
                                    bool boolValue = intValue == 1;
                                    instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, boolValue);
                                }
                                break;

                            case "byte[]":
                            case "Byte[]":
                                byte[] valorByte;

                                if (read[item.Name] != null && ((read[item.Name] as byte[]) != null))
                                {
                                    valorByte = (byte[])read[item.Name];
                                    instanceEntity.GetType().GetProperty(item.Name).SetValue(instanceEntity, valorByte);
                                }
                                break;
                            }
                        }

                        listObject.Add(instanceEntity);
                    }
                    return(listObject);
                }
            }
            //return null;
        }
 public static IList <T> GetAll(FilterCriteria filterCriteria)
 {
     return(GetAll(filterCriteria, "Id"));
 }