none
how to reference value in DataColumn Expressions

    質問

  • I have an existing expression like this

        DataTable1.Columns.Add("value", typeof(double), "rate * loan_amt");

    in a datatable with 10000 rows where rate is same for all rows and loan_amt varies

    When the rate changes, it changes for all
    currently that means iterating through all rows like so

         foreach(DataRow dr in DataTable1.Rows) dr["rate"] = new_rate;

    wondering if there's a better way using a ReferenceTable (with only 1 row ) in the same DataSet and linking it somehow like so

         DataTable1.Columns.Add("value", typeof(double), "RefTable.Row0.rate * loan_amt");

    so changing the rate would be as simple as

         RefTable.Rows[0]["rate"] = new_rate;


    Or is there any other way ?

    • 編集済み kumarnyc 2012年3月2日 22:14
    2012年3月2日 22:13

回答

  • Hi,

    you'd have to create a parent table with the one rate record (using a relation),

    create all your records refrencing the one record,

    and in the expression use:

    Parent.Rate * loan_amt

    Regards, Nico


    2012年3月5日 8:37

すべての返信