Back to Devexpress

XPBaseObject.SetMemberValue(String, Object) Method

xpo-devexpress-dot-xpo-dot-xpbaseobject-dot-setmembervalue-x28-system-dot-string-system-dot-object-x29.md

latest4.6 KB
Original Source

XPBaseObject.SetMemberValue(String, Object) Method

Sets the value of the specified property.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public void SetMemberValue(
    string propertyName,
    object newValue
)
vb
Public Sub SetMemberValue(
    propertyName As String,
    newValue As Object
)

Parameters

NameTypeDescription
propertyNameString

A String value which specifies the property name. If a property with the specified name isn’t found, a InvalidPropertyPathException is thrown.

| | newValue | Object |

An object which represents the new value.

|

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetMemberValue(String, Object) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

XPO_how-to-persist-metadata-e269/CS/Program.cs#L93

csharp
XPBaseObject customer = (XPBaseObject)classCustomer.CreateNewObject(dataSession);
customer.SetMemberValue("FullName", "John Doe");

CriteriaOperatorsCheatSheet/CS/CriteriaOperatorCheatSheet/Program.cs#L59

csharp
theObject = (T)Activator.CreateInstance(typeof(T), new object[] { session });
    ((XPCustomObject)(object)theObject).SetMemberValue(propertyName, value);
}

XPO_how-to-define-a-persistent-class-at-runtime-e1139/CS/CreateClassAtRuntime/Program.cs#L31

csharp
XPBaseObject obj = (XPBaseObject)myClassA.CreateNewObject(session);
obj.SetMemberValue("Name", String.Format("sample {0}", DateTime.UtcNow.Ticks));
obj.Save();

XAF_logon-form-manage-users-register-a-new-user-restore-a-password/CS/XPO/DXApplication1.Module/DatabaseUpdate/Updater.cs#L33

csharp
user.IsActive = true;
user.SetMemberValue("Email", email);
user.SetPassword(password);

XAF-implement-custom-permission-role-and-user-objects/CS/XPO/MySolutionXPO/MySolutionXPO.Module/DatabaseUpdate/MyUpdater.cs#L53

csharp
theObject = ObjectSpace.CreateObject<T>();
    ((XPBaseObject)(Object)theObject).SetMemberValue(propertyName, value);
}

XPO_how-to-persist-metadata-e269/VB/Program.vb#L83

vb
Dim customer As XPBaseObject = CType(classCustomer.CreateNewObject(dataSession), XPBaseObject)
customer.SetMemberValue("FullName", "John Doe")
For i As Integer = 0 To OrderCount - 1

See Also

GetMemberValue(String)

Delete Persistent Objects

XPBaseObject Class

XPBaseObject Members

DevExpress.Xpo Namespace