Вопрос

I want to do some thing like this.

Map = entitys => entitys.Select(entity=> 
                                new { Query = new object[]
                                        {
                                           entity.Name,
                                           entity.MyEnumValue.MyExtentsionMethod()
                                         }
                                    });

My Enum

public enum MyEnumValue
{
        [EnumMember(Value = "Value 1")]
        [Description("Value 1")]
        Value1,

        [EnumMember(Value = "Value 2")]
        [Description("Value 2")]
        Value2,  
}

MyExtensionMethod() will bring the friendly name for my Enum which i have specified for the Description.

I know the problem is that the User defined class are not available during the index creation. so i need a way to achieve this using the reflection or a proper way to retrieve this enum Description for indexing.

Thanks for any help.

Это было полезно?

Решение 2

This is what i end up doing

Map = entitys => entitys.Select(entity=> 
                                new { Query = new object[]
                                        {
                                           entity.Name,
                                           new[]{"Value 1","Value 2"}[(int)entity.])
                                         }
                                    });

the only downside is the hard coded string string but it works for me.

Другие советы

I suggest Compilation Extensions. Take a look at http://ravendb.net/docs/server/extending/plugins

You must inherit from AbstractDynamicCompilationExtension (like PalindromeDynamicCompilationExtension in the sample). Remember to upload your dll to Plugins folder of the RavenDB server.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top