MongoDB未知的鉴别值

时间:2013-07-01 22:09:41

标签: mongodb mongodb-.net-driver event-store neventstore

我在这个问题的答案中添加了代码:Unknown discriminator value 'MyEvent',但它没有帮助。

反序列化类EventStore.EventMessage的Body属性时发生错误:未知的鉴别符值:“插入事件名称”。 只有在程序重新启动后尝试重新合成已保存的对象时才会出现错误。

运行最新的MyGet Build

示例存储库:https://github.com/tonyeung/EventStore-MongoDB

要复制此问题:

运行程序
按c创建新记录
按q退出
再次运行程序
但按r重新水化
错误触发器

如果您运行该程序,请按c,按enter继续,然后按r重新水合而不退出,对象将被重新水合而不会出现问题。 WAT?

        using (var eventStore = WireupEventStore())
        {
            var snapshot = eventStore.Advanced.GetSnapshot(ID, int.MaxValue);
            if (snapshot == null)
            {
                // ERRORS HERE
                using (var stream = eventStore.OpenStream(ID, 0, int.MaxValue))
                {
                    var events = from s in stream.CommittedEvents
                                 select s.Body as IEvent;

                    obj.LoadsFromHistory(events);
                }
            }
        }

github问题:https://github.com/NEventStore/NEventStore/issues/203

1 个答案:

答案 0 :(得分:3)

我想通了,因为我使用界面作为事件的标记,我不得不从SO问题改变查询

        var types = Assembly.GetAssembly(typeof(SimpleCQRS.Event))
                .GetTypes()
                .Where(type => type.IsSubclassOf(typeof(SimpleCQRS.Event)));

        var type = typeof(IEvent);
        var types = Assembly.GetAssembly(typeof(IEvent))
                .GetTypes()
                .Where(t => type.IsAssignableFrom(t))
                .Where(t => t.IsClass);
相关问题