public class BZCustomerAttribute : CustomerAttribute
{
public BZCustomerAttribute(Type search)
: this(search, typeof(Customer.acctCD), typeof(Customer.acctName), typeof(Contact.phone1), typeof(Customer.primaryContactID), typeof(Customer.customerClassID), typeof(Address.addressLine1), typeof(Address.addressLine2),
typeof(Address.postalCode), typeof(Address.city), typeof(Address.countryID), typeof(Location.taxRegistrationID),
typeof(Customer.curyID), typeof(Contact.attention), typeof(Customer.customerClassID), typeof(Customer.status))
{
}
private readonly Type[] _fields;
[PXHidden]
[PXProjection(typeof(Select<Contact>))]
public class Contact2 : Contact
{
}
public BZCustomerAttribute(Type search, params Type[] fields)
{
Type genericTypeDefinition = search.GetGenericTypeDefinition();
Type[] genericArguments = search.GetGenericArguments();
Type type;
if (genericTypeDefinition == typeof(Search<>))
{
type = BqlCommand.Compose(typeof(Search2<,,>), typeof(BAccountR.bAccountID), typeof(LeftJoin<,,>), typeof(Customer),
typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>),
typeof(LeftJoin<,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
typeof(Where<Customer.bAccountID, IsNotNull>));
}
else if (genericTypeDefinition == typeof(Search<,>))
{
type = BqlCommand.Compose(typeof(Search2<,,>), typeof(BAccountR.bAccountID),
typeof(LeftJoin<,,>), typeof(Customer), typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>),
typeof(LeftJoin<,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
genericArguments[1]);
}
else if (genericTypeDefinition == typeof(Search<,,>))
{
type = BqlCommand.Compose(typeof(Search2<,,>), typeof(BAccountR.bAccountID),
typeof(LeftJoin<,,>), typeof(Customer), typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>),
typeof(LeftJoin<,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
genericArguments[1], genericArguments[2]);
}
else if (genericTypeDefinition == typeof(Search2<,>))
{
type = BqlCommand.Compose(typeof(Search2<,,>), typeof(BAccountR.bAccountID), typeof(LeftJoin<,,>), typeof(Customer),
typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
typeof(LeftJoin<,,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>),
genericArguments[1], typeof(Where<Customer.bAccountID, IsNotNull>));
}
else if (genericTypeDefinition == typeof(Search2<,,>))
{
type = BqlCommand.Compose(typeof(Search2<,,>), typeof(BAccountR.bAccountID), typeof(LeftJoin<,,>), typeof(Customer),
typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
typeof(LeftJoin<,,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>),
genericArguments[1], genericArguments[2]);
}
else
{
if (!(genericTypeDefinition == typeof(Search2<,,,>)))
{
throw new PXArgumentException("search", "An invalid argument has been specified.");
}
type = BqlCommand.Compose(typeof(Search2<,,>), typeof(BAccountR.bAccountID), typeof(LeftJoin<,,>), typeof(Customer),
typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
typeof(LeftJoin<,,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>),
genericArguments[1], genericArguments[2], genericArguments[3]);
}
PXDimensionSelectorAttribute pXDimensionSelectorAttribute;
_Attributes.Add(pXDimensionSelectorAttribute = new PXDimensionSelectorAttribute("BIZACCT", type, typeof(BAccountR.acctCD),
typeof(BAccountR.acctCD), typeof(Customer.acctName), typeof(Contact.phone1), typeof(Contact2.firstName),
typeof(Customer.customerClassID), typeof(Customer.status), typeof(Address.city), typeof(Address.countryID),
typeof(Address.addressLine1), typeof(Address.addressLine2), typeof(Address.postalCode)));
//_Attributes.Add(pXDimensionSelectorAttribute = new PXDimensionSelectorAttribute("BIZACCT", type, typeof(BAccountR.acctCD),
// typeof(BAccountR.acctCD), typeof(Customer.acctName), typeof(Contact.phone1), typeof(Contact2.firstName),
// typeof(Customer.customerClassID), typeof(Customer.status), typeof(Address.city), typeof(Address.countryID),
// typeof(Address.addressLine1), typeof(Address.addressLine2), typeof(Address.postalCode)));
pXDimensionSelectorAttribute.DescriptionField = typeof(Customer.acctName);
pXDimensionSelectorAttribute.CacheGlobal = true;
pXDimensionSelectorAttribute.FilterEntity = typeof(Customer);
_SelAttrIndex = _Attributes.Count - 1;
Filterable = true;
_fields = fields;
//Type genericTypeDefinition = search.GetGenericTypeDefinition();
//Type[] genericArguments = search.GetGenericArguments();
//Type type;
//type = BqlCommand.Compose(typeof(Search2<,>), typeof(BAccountR.bAccountID),
// typeof(LeftJoin<,>), typeof(Customer), typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
// typeof(LeftJoin<,>), typeof(Contact), typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
// typeof(LeftJoin<,>), typeof(Address), typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
// typeof(LeftJoin<,>), typeof(Location), typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
// typeof(LeftJoin<,>), typeof(Contact2), typeof(On<Contact2.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.primaryContactID>>>));
//PXDimensionSelectorAttribute pXDimensionSelectorAttribute;
//_Attributes.Add(pXDimensionSelectorAttribute = new PXDimensionSelectorAttribute("BIZACCT", type, typeof(BAccountR.acctCD),
// typeof(BAccountR.acctCD), typeof(Customer.acctName), typeof(Contact.phone1), typeof(Contact2.firstName),
// typeof(Customer.customerClassID), typeof(Customer.status), typeof(Address.city), typeof(Address.countryID),
// typeof(Address.addressLine1), typeof(Address.addressLine2), typeof(Address.postalCode)));
//pXDimensionSelectorAttribute.DescriptionField = typeof(Customer.acctName);
//pXDimensionSelectorAttribute.CacheGlobal = true;
//pXDimensionSelectorAttribute.FilterEntity = typeof(Customer);
//_SelAttrIndex = _Attributes.Count - 1;
//Filterable = true;
//_fields = fields;
}
}When I want to add a join to the same DAC in one BQL command using another key, I cannot do it. How can I get the telephone from Contact by DefaultContactID and the primary contact name by PrimaryContactID?




