创建从其他DAC继承的DAC [英] Create DAC that inherits from other DAC

查看:59
本文介绍了创建从其他DAC继承的DAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Acumatica中,某些情况下,屏幕的DAC(例如Projects)没有直接绑定到表(PMProject),而是继承了绑定到表的DAC(合同)。

In Acumatica, there are instances where a DAC for a screen (e.g., Projects) is not directly bound to a table (PMProject), but inherits a DAC that IS bound to a table (Contract). Is there a good instructional reference source for doing this?

推荐答案

此主题在T200培训课程中得到了部分覆盖(示例9.1)。

This theme is partially covered in T200 training course(Example 9.1).

基本原理:

如果您从绑定到SQL表的DAC1继承了某些类DAC2,则DAC2将

If you inherited some class DAC2 from the DAC1 bound to the SQL table then DAC2 will also be bound to the same SQL table.

[Serializable]
public partial class DAC1 : IBQLTable
{
    public abstract class tableID : PX.Data.IBqlField
    {
    }
    [PXDBIdentity()]
    public virtual Int32? TableID { get; set;}
}
[Serializable]
public partial class DAC2 : DAC1
{}

但是,DAC1中的字段将用于生成的SQL查询。

However, fields from DAC1 will be used in the generated SQL query.

PXSelect<DAC2, Where<DAC2.tableID, Equal<Required<DAC2.tableID>>>(...) ->
SELECT [DAC2].[TableID] FROM DAC1 DAC2 Where [DAC1].[TableID] = @P0

要允许BQL使用DAC2字段生成SQL查询,您应该在DAC2中替换该字段的抽象类

To allow BQL generate SQL queries with DAC2 field you should replace abstract class of this field in DAC2

[Serializable]
public partial class DAC2 : DAC1
{
    public new abstract class tableID : PX.Data.IBqlField
    {
    }
}

SQL查询看起来像这样:

SQL query will look like that:

SELECT [DAC2].[TableID] FROM DAC1 DAC2 Where [DAC2].[TableID] = @P0

要覆盖该字段的属性,您应该覆盖DAC2中的相应属性

To override attributes of the field you should override corresponding property in DAC2

[Serializable]
public partial class DAC2 : DAC1
{
    public new abstract class tableID : PX.Data.IBqlField
    {
    }
    [PXDBIdentity()]
    [PXUIField(DisplayName = "ID")]
    public override Int32? TableID {get; set;}
}

例如,如果您希望DAC2与DAC1不同想要向DAC2中添加一些字段,但您也想保持DAC1不变,那么可以使用PXTable属性(例如ARInvoice类)

If you want DAC2 to be different from DAC1, for instance you want to add some fields to DAC2 but you also want to keep DAC1 unmodified then you can use PXTable attribute(e.g. ARInvoice class)

[PXTable]
[Serializable]
public partial class DAC2 : DAC1
{
    public new abstract class tableID : PX.Data.IBqlField
    {
    }
    [PXDBIdentity()]
    [PXUIField(DisplayName = "ID")]
    public override Int32? TableID {get; set;}

    public abstract class description : PX.Data.IBqlField
    {
    }
    [PXDBString(60)]
    public virtual String Description{get; set;}
}

SQL查询如下所示:

The SQL query will look like that:

SELECT [DAC2].[TableID], [DAC2.Description] 
FROM (SELECT [DAC1].[TableID] as TableID, [DAC2].[Description] as Description 
    FROM DAC1 Inner Join DAC2 on DAC1.TableID=DAC2.TableID) DAC2 
Where [DAC2].[TableID] = @P0

这篇关于创建从其他DAC继承的DAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆