We have tried searching stackoverflow & other places but could not find a solution.
We have a class which is like this.
class UserAccountInfo
{
public String someid;
public Object needtoqueryobject; //This can store different object types like AccountInfoCustomer, AccountInfoFriend etc.,
}
We want to query this class like as follows.
var Result = sess.Query<UserAccountInfo>().Where(x => ((AccountInfoCustomer)x.needtoqueryobject).AccountType == usertype);
But this is not supported and it says unable to query on unindexed fields. We can understand that RavenDB is unable to index this particular type as it does not understand the actual type. Can someone explain how to make sure these classes are also indexed?
Added the AccountInfoCustomer type definition:
using System;
namespace Dheutto.Models
{
public enum AccountTypes
{
Customer,
Trader,
Distributor
}
public class AccountInfoCustomer
{
//The AccountNumber for the document
public String FirstName { get; set; }
public String MiddleName { get; set; }
public String LastName { get; set; }
public String Father_spouse_Name { get; set; }
public AccountTypes AccountType{ get; set; }
}
}
This AccountInfoCustomer type is what is stored as object in the needtoqueryobject field. So when I do a query with a typecast, I am expecting it to return some result. Correct me if I am wrong.
If you have an object in your entity, you can’t query that using linq.
You can query that using the LuceneQuery, and the untyped syntax.