Using view with composite key of boolean and enum values


#1

Hey,

Assume i have an entity with this structure:

public class Entity 
{
public string Name {get;set;}

 [CouchbaseViewKey("promotionbyenvironmentandisactive", "IsActive", 1)]
        public bool IsActive { get; set; }

  [CouchbaseViewKey("promotionbyenvironmentandisactive", "Environment")]
        public EnvironmentOptions Environment
        {
            get
            {
                return (EnvironmentOptions)environment;
            }
            set
            {
                environment = value;
            }
        }
}

And i want to get all the Entity objects where IsActive=true and Environment=.
How do i fetch it correctly from view?

I created a view :

function(doc, meta) {
	if (doc.type == "Promotion" && doc.Environment && doc.IsActive) {
		emit([doc.Environment, doc.IsActive], null);
	}
} 

and trying to fetch the data this way:

GetView(ViewName...).Key(new[] { env.ToString(), isActive.ToString().ToLower() });

It is not working since i see the data is indexed in the view this way: [2,true] for example
and when trying to use Key method i have to send string keys while i know my keys are not strings.

How can i solve it ? i do not want to change my properties types in my class to string…i want them to stay in the same type.