public ReferenceByIntProperty(ReferencableMasterInfo source, string idPropertyName)
 {
     Source = source;
     PropertyToReference = Source.Type.GetProperty(idPropertyName);
     IntValue            = SelectedObject.Where(x => x != null)
                           .Select(x => (int)(PropertyToReference?.GetValue(x) ?? -1))
                           .ToReactiveProperty(-1);
     Value = IntValue.Select(x => (object)x).ToReactiveProperty();
 }
        public void SetItemById(int id)
        {
            if (PropertyToReference == null)
            {
                throw new InvalidOperationException();
            }

            var obj = Source.Collection.FirstOrDefault(x => (int)PropertyToReference.GetValue(x) == id);

            if (obj != null)
            {
                SelectedObject.Value = obj;
            }
        }