How to Ignore CustomSelect member from POCO

Hi,

I have one POCO class, whose partial class is used to extend foreign key ref. Within same partial class I have one more member with [CustomSelect] attribute(which is not present physically). Now this POCO class is used to query in two different service/end points. One service has custom query which needs this customselect member, however other do not needed it. Hence when I call the service with second end point, it throws exception “The multi-part identifier could not be bound”.
Can you give me an idea, how to use this customselect member in autoquery of one service and avoide/ignore it for another service ?

E.g. Following is POCO class-
[Alias(“ProjectTask”)]
public partial class ProjectTask : IHasId
{
public ProjectTask()
{
}

    [Alias("Id")]
    [AutoIncrement]
    public int Id { get; set; }
    [References(typeof(Client))]
    [Required]
    public int ClientId { get; set; }
    [Required]
    public string Name { get; set; }
    [Compute]        
     [Required]
    public string Display { get; set; }
    public string Description { get; set; }

}

And this is its partial class -
public partial class ProjectTask
{
[Reference]
public Client Client { get; set; }
[Reference]
public ProjectTaskType ProjectTaskType { get; set; }
[CustomSelect(@"(SELECT PT.Name)")]
public string ProjectTaskName { get; set; }
}

In one end point/service which is using custom query during Select, we are using ProjectTask table name as psudo name “PT” whereas in another Select end point/service which is plain query we are not using this field. But when we call this plain Select query, it throws exception- The multi-part identifier could not be bound. which is obvious.
Can you give me hint/way to ignore/not ignore this member based on endpoint/service called from ?

Thanks in advance

You can’t ignore or selectively apply an attribute, it’s fixed metadata about the class it’s annotating.

You’d need to create another class with the same properties but without the attributes or properties you don’t want.

You can use the [Alias] attribute to specify the class should map to a specific table, e.g:

[Alias(nameof(ProjectTask))]
class MyProjectTask { ... }

If you ever need to map between them you can use the built-in Auto Mapping Utils, e.g:

var to = row.ConvertTo<MyProjectTask>();