How to get parent value from child?

Issue #144 new
qlmanlp created an issue

I have pivot table, where 3 foreign keys and 1 values, how to get values parents from foreign keys?

Comments (2)

  1. qlmanlp reporter

    Table

        [Table("ParameterValue")]
        public class ParameterValue
        {
            [PrimaryKey, AutoIncrement, Column("_Id")]
            public int ParameterValue_Id { get; set; }
    
            [ForeignKey(typeof(Profile))]
            public int ParameterValue_ProfileID { get; set; }
    
            [ForeignKey(typeof(Parameter))]
            public int ParameterValue_ParameterID { get; set; }
    
            public string ParameterValue_Value { get; set; }
    
            [ForeignKey(typeof(Unit))]
            public int ParameterValue_Unit { get; set; }
        }
    

  2. qlmanlp reporter

    Hello, i found solution.

    1. Need LINQ query

      var q = from a in parameters
      join b in unitcategories on a.Parameter_UnitCategoryID equals b.UnitCategory_Id join c in unitcategoriestype on b.UnitCategory_TypeID equals c.UnitCategoryType_Id select new ParameterUnitCategory{ PUC_ID = a.Parameter_Id, PUC_ParameterName = a.Parameter_Name, PUC_UnitCategoryTypeID = b.UnitCategory_TypeID, PUC_UnitCategoryTypeName = c.UnitCategoryType_Name };
      return q;

    2. Need new Class with types parent attribute

    public class ParameterParentValue
    {
    public int P_Id { get; set; }
    public string P_ParameterName { get; set; }
    public string P_Value { get; set; }
    public string P_UnitName { get; set; }
    }

  3. Log in to comment