Please ignore any syntax errors I may have made while typing the following up:
Schema.SObjectType t = custom__c.sObjectType;
// The following succeeds
String query = 'select id, name from ' + t + ' order by name';
List<custom__c> customs = Database.query(query);
// The following fails
query = 'select id, name from ' + t + ' where attrib__c = ' + t.substring(1,5);
List<custom__c> customs = Database.query(query);
query = 'select id, name from ' + t + ' where attrib__c = ' + t.toString().substring(1,5);
List<custom__c customs = Database.query(query);
query = 'select id, name from ' + t + ' where attrib__c = ' + ((String)t).substring(1,5);
List<custom__c> customs = Database.query(query);
I can not figure out how to obtain a substring of the sOjectType. I am using this for dynamic soql.
Is this possible?
Thanks!