Hi,

How can I perform a query on a property that is mapped as <any> ?

For example:

<any name="Client" meta-type="string" id-type="Int32" cascade="none" 
lazy="false" >
      <meta-value value="Impressora" class="Printer" />
      <meta-value value="Funcionario" class="Employee" />
      <meta-value value="Cliente_externo" class="ExternalClient" />
      <meta-value value="Fornecedor" class="Supplier" />
      
      <column name="TP_CLIENTE" />
      <column name="CD_CLIENTE" />
</any>

this are my classes:

public class Client : EntityBase
{
public virtual string Name { get; set; }
public virtual string PhoneNumber { get; set; }
public virtual string Code { get; set; }
public virtual string Email { get; set; }
public virtual ClientType ClientType { get; set; }
}

public class Employee : Client
{
public Employee()
{
this.ClientType = ClientType.Employee;
}

public virtual Company Company { get; set; }
public virtual string ActiveDirectoryName { get; set; }
public virtual string Login { get; set; }
}

public class ExternalClient : Client
{
public ExternalClient()
{
this.ClientType = Enums.ClientType.ExternalClient;
}

public virtual string CityName { get; set; }
}

public class Supplier : Client
{
public Supplier()
{
this.ClientType = Enums.ClientType.Supplier;
}

public virtual string CityName { get; set; }
}

public class Printer : Client
{
public Printer()
{
this.ClientType = Enums.ClientType.Printer;
}
}


How can I can query by Employee.Name?

I'm trying to do this:

public IList<Request> ListRequests(RequestFinder finder, int pageSize, int 
currentPage)
{
Criticality criticalityAlias = null;
Request requestAlias = null;

Employee employeeAlias = null;
Supplier supplierAlias = null;
Printer printerAlias = null;
ExternalClient externalClientAlias = null;

var reqs = this.UnitOfWork.CurrentSession.QueryOver<Request>(() => 
requestAlias)
.Inner.JoinAlias(() => requestAlias.Criticality, () => criticalityAlias)
.Left.JoinAlias(() => requestAlias, () => employeeAlias);

if (finder.CriticalityId.HasValue)
{
reqs = reqs.Where(() => criticalityAlias.Id == finder.CriticalityId.Value);
}

if (!string.IsNullOrEmpty(finder.ClientName))
{
reqs.Where(() => employeeAlias.Name == finder.ClientName);
}

reqs
.OrderBy(x => x.Id)
.Desc
.Skip((currentPage - 1) * pageSize)
.Take(pageSize);

return reqs.List();
}


but I'm getting an exception that says: "any types do not have a unique 
referenced persister"

Is it possible?!

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/myns_8YwAjYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to