Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • In version 17.1, we have improved error detection in XPQuery when non-persistent properties are used in it. Previously, such queries didn't work (either failed with various exceptions or worked incorrectly) and thus there were hidden errors in your programs. Now, we throw an exception that describes which non-persistent properties are used in XPQuery to help diagnosing these errors. If such properties are used intentionally, consider implementing them using PersistentAliasAttribute or adding the ToList method call to explicitly process these properties on the client side.

                                    For example, the following code now throws an exception:
                                    [C#]
                                    public class Person: XPObject { string _firstName; public string FirstName { get { return _firstName; } set { SetPropertyValue("FirstName", ref _firstName, value); } } string _lastName; public string LastName { get { return _lastName; } set { SetPropertyValue("LastName", ref _lastName, value); } } public string NonPersistentProperty { get { return FirstName + " " + LastName; } } } //... var query = new XPQuery<Person>(uow).Where(p => p.FirstName == "John" && p.NonPersistentProperty.Contains("Jr"))
                                    [VB.NET]
                                    Public Class Person Inherits XPObject Private _firstName As String Public Property FirstName() As String Get Return _firstName End Get Set(ByVal value As String) SetPropertyValue("FirstName", _firstName, value) End Set End Property Private _lastName As String Public Property LastName() As String Get Return _lastName End Get Set(ByVal value As String) SetPropertyValue("LastName", _lastName, value) End Set End Property Public ReadOnly Property NonPersistentProperty() As String Get Return FirstName & " " & LastName End Get End Property End Class '... Dim query = (New XPQuery(Of Person)(uow)).Where(Function(p) p.FirstName = "John" AndAlso p.NonPersistentProperty.Contains("Jr"))

                                    It can be fixed by rewriting the query with the ToList method to process a part of the query on the client side:
                                    [C#]
                                    var query = new XPQuery<Person>(uow).Where(p => p.FirstName == "John").ToList().Where(p => p.NonPersistentProperty.Contains("Jr"));
                                    [VB.NET]
                                    Dim query = (New XPQuery(Of Person)(uow)).Where(Function(p) p.FirstName = "John").ToList().Where(Function(p) p.NonPersistentProperty.Contains("Jr"))

                                    It can also be fixed by implementing the property using PersistentAliasAttribute:
                                    [C#]
                                    public class Person : XPObject { //... [PersistentAlias("Concat(FirstName, ' ', LastName")] public string NonPersistentProperty { // It is persistent now get { return (string)EvaluateAlias("NonPersistentProperty"); } } }
                                    [VB.NET]
                                    Public Class Person Inherits XPObject '... <PersistentAlias("Concat(FirstName, ' ', LastName")> Public ReadOnly Property NonPersistentProperty() As String ' It is persistent now Get Return CStr(EvaluateAlias("NonPersistentProperty")) End Get End Property End Class

                                    Search keywords: NotSupportedException, InvalidOperationException,  LINQ, 17.1, XPQuery<T>, "The expression is not supported in the Where clause"

                                0 Solutions

                                Creation Date Rating Importance Sort by

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners