The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Collection.Filter() and Ampersands

Last post 06-19-2008, 9:14 AM by chuckdfoster. 2 replies.
Sort Posts: Previous Next
  •  06-19-2008, 8:28 AM 9892

    Collection.Filter() and Ampersands

    I am using ES 2007 with C# ASP.NET and SQL Server 2005.  I am having an issue with using the Collection.Filter() when the search value includes an ampersand.  Could you give me any insight to why this is happening?  My code is below (by the way, your Source Code entry window is not currently working).  When roleName's value = "Stanley Supply & Services, Inc." no records are found, even though "Stanley Supply & Services, Inc." exists in the UserRole table and in the current UserRoleCollection.

    public partial class UserRoleCollection : esUserRoleCollection
        { ....
     
            public UserRole FindByName(string roleName)
            {
                UserRole foundRole = null;
                this.Filter = String.Format("{0} = '{1}'", UserRoleMetadata.ColumnNames.RoleName, roleName);
                if (this.Count == 1)
                {
                    foundRole = this[0];
                }
                this.Filter = String.Empty;

                return foundRole;
            }

    ... }


    chuck foster
    .net/sql server developer
  •  06-19-2008, 9:02 AM 9895 in reply to 9892

    Re: Collection.Filter() and Ampersands

    We merely pass your string straight through to the ADO.NET DataView.RowFilter property. I'm curious are you using .NET 2.0 or 3.5?

    Also, see this post.  If you are using .NET 3.5 I can show you a much better way with Lambda expressions.


    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  06-19-2008, 9:14 AM 9896 in reply to 9895

    Re: Collection.Filter() and Ampersands

    My bad!  It was actually a problem with the way I was passing the values in.  They were being HTML Encoded from a GridView.  Guess I was too quick to blame ES, huh?  Thanks for the quick response though.

    chuck foster
    .net/sql server developer
View as RSS news feed in XML