Archives

Archives / 2015 / September
  • Override Equals method of value types

    Hello everybody.

    Today I want to give some demo.

    using System;

    using System.Diagnostics;

    namespace StackOverflowQuest

    {

    class Program

    {

    struct StructTest

    {

    public string TestString { get; set; }

    //public override bool Equals(object obj)

    //{

    // var ct = (StructTest)obj;

    // return ct.TestString == this.TestString;

    //}

    }

    class ClassTest

    {

    public string TestString { get; set; }

    public override bool Equals(object obj)

    {

    var ct = obj as ClassTest;

    if (ct == null) … more

  • How to set current record in Acumatica

    Hello everybody,

    today I want to share one trick which can save you few lines of code.

    Imagine case: you created graph, and want to read something from db, and then set current property of that graph view to some value. How to do it in one line? The anser is simple, with help of Search<>

    For example it can be like this:

    public PXSelectOrderBy<SalesOrder, OrderBy<Asc<SalesOrder.orderNbr>>> Orders;

    ...

    graph.Orders.Current = graph.Orders.Search<SalesOrder.orderNbr>(order.OrderNbr); more

  • Inheritance strategy in code-first

    Hello everybody,

    today I want to write about reflecting hierarchy of classes in db with help of code-first.

    There are three types: 

    Table per Hierarchy

    Table per Type

    Table per conreate class.

    Below goes more detailed description

    Table per Hierarchy (TPH): one table for the entire class inheritance hierarchy. Table includes discriminator column which distinguishes between inheritance classes. This is a default inheritance mapping strategy in Entity Framework.

    Table per Type (TPT): This approach suggests a separate table for each domain class.

    Table per Concrete class (TPC): one table for one concrete class, but not for the abstract class. So, if you inherit the abstract … more