internal virtual StringBuilder GetAutoPropertyFilterString()
        {
            var res = new StringBuilder();


            if (string.IsNullOrEmpty(idFilter) == false)
            {
                res.Append(" && " + string.Format("id.Contains(\"{0}\")", idFilter));
            }


            if (string.IsNullOrEmpty(CNumberFilter) == false)
            {
                res.Append(" && " + string.Format("CNumber.Contains(\"{0}\")", CNumberFilter));
            }



            if (Convert.ToDateTime(StartRegistrationDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndRegistrationDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" && (");
            }

            if (Convert.ToDateTime(StartRegistrationDateFilter).Date != DateTime.MinValue)
            {
                if (StartRegistrationDateFilter.HasValue)
                {
                    res.Append(
                        (Convert.ToDateTime(EndRegistrationDateFilter).Date != DateTime.MinValue?"":" && ") +
                        string.Format("RegistrationDate >= \"{0}\"", Convert.ToDateTime(StartRegistrationDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }

            if (Convert.ToDateTime(EndRegistrationDateFilter).Date != DateTime.MinValue)
            {
                if (EndRegistrationDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("RegistrationDate <= \"{0}\"", Convert.ToDateTime(EndRegistrationDateFilter).Date.AddHours(23).ToString("MM/dd/yyyy HH:mm:ss")));
                }
            }

            if (Convert.ToDateTime(StartRegistrationDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndRegistrationDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" )");
            }

            if (Convert.ToDateTime(_registrationDateFilter).Date != DateTime.MinValue)
            {
                if (RegistrationDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("RegistrationDate == \"{0}\"", Convert.ToDateTime(RegistrationDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }


            if (IsManuallyAssessedFilter.HasValue)
            {
                res.Append(" && " + string.Format("IsManuallyAssessed == {0}", IsManuallyAssessedFilter));
            }


            if (string.IsNullOrEmpty(ReferenceNumberFilter) == false)
            {
                res.Append(" && " + string.Format("ReferenceNumber.Contains(\"{0}\")", ReferenceNumberFilter));
            }



            if (Convert.ToDateTime(StartEffectiveRegistrationDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndEffectiveRegistrationDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" && (");
            }

            if (Convert.ToDateTime(StartEffectiveRegistrationDateFilter).Date != DateTime.MinValue)
            {
                if (StartEffectiveRegistrationDateFilter.HasValue)
                {
                    res.Append(
                        (Convert.ToDateTime(EndEffectiveRegistrationDateFilter).Date != DateTime.MinValue?"":" && ") +
                        string.Format("EffectiveRegistrationDate >= \"{0}\"", Convert.ToDateTime(StartEffectiveRegistrationDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }

            if (Convert.ToDateTime(EndEffectiveRegistrationDateFilter).Date != DateTime.MinValue)
            {
                if (EndEffectiveRegistrationDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("EffectiveRegistrationDate <= \"{0}\"", Convert.ToDateTime(EndEffectiveRegistrationDateFilter).Date.AddHours(23).ToString("MM/dd/yyyy HH:mm:ss")));
                }
            }

            if (Convert.ToDateTime(StartEffectiveRegistrationDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndEffectiveRegistrationDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" )");
            }

            if (Convert.ToDateTime(_effectiveRegistrationDateFilter).Date != DateTime.MinValue)
            {
                if (EffectiveRegistrationDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("EffectiveRegistrationDate == \"{0}\"", Convert.ToDateTime(EffectiveRegistrationDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }


            if (DoNotAllocateFilter.HasValue)
            {
                res.Append(" && " + string.Format("DoNotAllocate == {0}", DoNotAllocateFilter));
            }


            if (AutoUpdateFilter.HasValue)
            {
                res.Append(" && " + string.Format("AutoUpdate == {0}", AutoUpdateFilter));
            }


            if (string.IsNullOrEmpty(BLNumberFilter) == false)
            {
                res.Append(" && " + string.Format("BLNumber.Contains(\"{0}\")", BLNumberFilter));
            }


            if (string.IsNullOrEmpty(DescriptionFilter) == false)
            {
                res.Append(" && " + string.Format("Description.Contains(\"{0}\")", DescriptionFilter));
            }


            if (string.IsNullOrEmpty(Type_of_declarationFilter) == false)
            {
                res.Append(" && " + string.Format("Type_of_declaration.Contains(\"{0}\")", Type_of_declarationFilter));
            }


            if (string.IsNullOrEmpty(Declaration_gen_procedure_codeFilter) == false)
            {
                res.Append(" && " + string.Format("Declaration_gen_procedure_code.Contains(\"{0}\")", Declaration_gen_procedure_codeFilter));
            }


            if (string.IsNullOrEmpty(Extended_customs_procedureFilter) == false)
            {
                res.Append(" && " + string.Format("Extended_customs_procedure.Contains(\"{0}\")", Extended_customs_procedureFilter));
            }


            if (string.IsNullOrEmpty(Country_first_destinationFilter) == false)
            {
                res.Append(" && " + string.Format("Country_first_destination.Contains(\"{0}\")", Country_first_destinationFilter));
            }


            if (string.IsNullOrEmpty(Currency_codeFilter) == false)
            {
                res.Append(" && " + string.Format("Currency_code.Contains(\"{0}\")", Currency_codeFilter));
            }


            if (Currency_rateFilter.HasValue)
            {
                res.Append(" && " + string.Format("Currency_rate == {0}", Currency_rateFilter.ToString()));
            }

            if (string.IsNullOrEmpty(Manifest_reference_numberFilter) == false)
            {
                res.Append(" && " + string.Format("Manifest_reference_number.Contains(\"{0}\")", Manifest_reference_numberFilter));
            }


            if (string.IsNullOrEmpty(Customs_clearance_office_codeFilter) == false)
            {
                res.Append(" && " + string.Format("Customs_clearance_office_code.Contains(\"{0}\")", Customs_clearance_office_codeFilter));
            }


            if (LinesFilter.HasValue)
            {
                res.Append(" && " + string.Format("Lines == {0}", LinesFilter.ToString()));
            }

            if (string.IsNullOrEmpty(DocumentTypeFilter) == false)
            {
                res.Append(" && " + string.Format("DocumentType.Contains(\"{0}\")", DocumentTypeFilter));
            }


            if (ImportCompleteFilter.HasValue)
            {
                res.Append(" && " + string.Format("ImportComplete == {0}", ImportCompleteFilter));
            }


            if (CancelledFilter.HasValue)
            {
                res.Append(" && " + string.Format("Cancelled == {0}", CancelledFilter));
            }


            if (TotalCIFFilter.HasValue)
            {
                res.Append(" && " + string.Format("TotalCIF == {0}", TotalCIFFilter.ToString()));
            }

            if (TotalGrossWeightFilter.HasValue)
            {
                res.Append(" && " + string.Format("TotalGrossWeight == {0}", TotalGrossWeightFilter.ToString()));
            }
            return(res.ToString().StartsWith(" &&") || res.Length == 0 ? res:  res.Insert(0, " && "));
        }
        internal virtual StringBuilder GetAutoPropertyFilterString()
        {
            var res = new StringBuilder();


            if (string.IsNullOrEmpty(Declarant_Reference_NumberFilter) == false)
            {
                res.Append(" && " + string.Format("Declarant_Reference_Number.Contains(\"{0}\")", Declarant_Reference_NumberFilter));
            }


            if (Exchange_RateFilter.HasValue)
            {
                res.Append(" && " + string.Format("Exchange_Rate == {0}", Exchange_RateFilter.ToString()));
            }

            if (string.IsNullOrEmpty(Country_of_origin_codeFilter) == false)
            {
                res.Append(" && " + string.Format("Country_of_origin_code.Contains(\"{0}\")", Country_of_origin_codeFilter));
            }


            if (string.IsNullOrEmpty(Currency_CodeFilter) == false)
            {
                res.Append(" && " + string.Format("Currency_Code.Contains(\"{0}\")", Currency_CodeFilter));
            }


            if (string.IsNullOrEmpty(DescriptionFilter) == false)
            {
                res.Append(" && " + string.Format("Description.Contains(\"{0}\")", DescriptionFilter));
            }


            if (string.IsNullOrEmpty(Manifest_NumberFilter) == false)
            {
                res.Append(" && " + string.Format("Manifest_Number.Contains(\"{0}\")", Manifest_NumberFilter));
            }


            if (string.IsNullOrEmpty(BLNumberFilter) == false)
            {
                res.Append(" && " + string.Format("BLNumber.Contains(\"{0}\")", BLNumberFilter));
            }



            if (Convert.ToDateTime(StartEntryTimeStampFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndEntryTimeStampFilter).Date != DateTime.MinValue)
            {
                res.Append(" && (");
            }

            if (Convert.ToDateTime(StartEntryTimeStampFilter).Date != DateTime.MinValue)
            {
                if (StartEntryTimeStampFilter.HasValue)
                {
                    res.Append(
                        (Convert.ToDateTime(EndEntryTimeStampFilter).Date != DateTime.MinValue?"":" && ") +
                        string.Format("EntryTimeStamp >= \"{0}\"", Convert.ToDateTime(StartEntryTimeStampFilter).Date.ToString("MM/dd/yyyy")));
                }
            }

            if (Convert.ToDateTime(EndEntryTimeStampFilter).Date != DateTime.MinValue)
            {
                if (EndEntryTimeStampFilter.HasValue)
                {
                    res.Append(" && " + string.Format("EntryTimeStamp <= \"{0}\"", Convert.ToDateTime(EndEntryTimeStampFilter).Date.AddHours(23).ToString("MM/dd/yyyy HH:mm:ss")));
                }
            }

            if (Convert.ToDateTime(StartEntryTimeStampFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndEntryTimeStampFilter).Date != DateTime.MinValue)
            {
                res.Append(" )");
            }

            if (Convert.ToDateTime(_entryTimeStampFilter).Date != DateTime.MinValue)
            {
                if (EntryTimeStampFilter.HasValue)
                {
                    res.Append(" && " + string.Format("EntryTimeStamp == \"{0}\"", Convert.ToDateTime(EntryTimeStampFilter).Date.ToString("MM/dd/yyyy")));
                }
            }


            if (StartingFileCountFilter.HasValue)
            {
                res.Append(" && " + string.Format("StartingFileCount == {0}", StartingFileCountFilter.ToString()));
            }

            if (DocumentsCountFilter.HasValue)
            {
                res.Append(" && " + string.Format("DocumentsCount == {0}", DocumentsCountFilter.ToString()));
            }

            if (ApportionMethodFilter.HasValue)
            {
                res.Append(" && " + string.Format("ApportionMethod == {0}", ApportionMethodFilter.ToString()));
            }

            if (TotalCIFFilter.HasValue)
            {
                res.Append(" && " + string.Format("TotalCIF == {0}", TotalCIFFilter.ToString()));
            }

            if (TotalGrossWeightFilter.HasValue)
            {
                res.Append(" && " + string.Format("TotalGrossWeight == {0}", TotalGrossWeightFilter.ToString()));
            }
            return(res.ToString().StartsWith(" &&") || res.Length == 0 ? res:  res.Insert(0, " && "));
        }