Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7019511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:11:35+00:00 2026-05-27T23:11:35+00:00

Is it possible to index the value of an Enum instead of its string

  • 0

Is it possible to index the value of an Enum instead of its string representation using Solrnet?

Say I have to following enum:

[Serializable]
[Flags] 
public enum Gender
{
  Male = 0,
  Female = 1
}

and add a solr attribute to the Gender property of a User class:

[SolrField("gender")]
public virtual Gender Gender { get; set; }

If I index the entity using:

solr.Add(user)

then it will index ‘Male’ as gender instead of 0. Is it possible to have it index 0 instead?

Edit: I’d prefer not to add an extra property for this, like Ondrej proposes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:11:36+00:00Added an answer on May 27, 2026 at 11:11 pm

    You can do this by implementing ISolrFieldSerializer. If the type IsEnum, serialize by casting to int. Otherwise delegate to DefaultFieldSerializer. Use the other field serializers for reference.

    Hooking up your field serializer depends on the chosen IoC container, check the container’s documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question. Is it possible to replace the following code: document.form_name.element_name with document.form_name.<array[index].value> ?
Is it possible to use an index integer to obtain an enum value? For
Is it possible to create an index that has as one of its columns
Is it possible to start an array at an index not zero...I.E. you have
I'm wondering if its possible to pause a clustered index whenever bulk data is
I was wondering if it's possible to get the index value of the underlying
I want to add a z-index value to a div that I don't have
How is is possible, using PHP to add a new index to each 'level'
Is it possible to call a function on specific index value of nodelist which
If I can access an object from an object using list[value][index] , how can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.