0

My English is not good, so i just can describe the problem i got as what as I can. I got 2 entities which are WORK_ORDER and INVENTORY_TRANS, and i have join these tables for querying, before I do the table splitting on WORK_ORDER, everything is working fine. in some reason, i have to do table splitting on WORK_ORDER, and after that, the join query is not working anymore.

i have pasted the code snippet below:

query = from w in context.WORK_ORDERV7
                join iv in context.INVENTORY_TRANS on
                new { WO = w.BASE_ID, LOT_ID = w.LOT_ID, SPLIT_ID = w.SPLIT_ID, SUB_ID = w.SUB_ID } equals
                new { WO = iv.WORKORDER_BASE_ID, LOT_ID = iv.WORKORDER_LOT_ID, SPLIT_ID = iv.WORKORDER_SPLIT_ID, SUB_ID = iv.WORKORDER_SUB_ID }
                where w.STATUS != "C" && System.Data.Entity.DbFunctions.TruncateTime(iv.TRANSACTION_DATE) == System.Data.Entity.DbFunctions.TruncateTime(DateTime.Now)
                && iv.WORKORDER_TYPE == "W" && iv.TYPE == "O" && iv.CLASS == "I"
                orderby iv.CREATE_DATE descending
                select new WOInProgressReference
                {
                    LastPartIssued = iv.PART_ID,
                    Part = w.PART_ID,
                    LastPartIssuedDateTime = iv.CREATE_DATE,
                    UserID = iv.USER_ID,
                    Warehouse = iv.WAREHOUSE_ID,
                    WO_Lot_Sub_Split = w.BASE_ID + "," + w.LOT_ID + "," + w.SUB_ID + "," + w.SPLIT_ID
                };

The error I got which is about the PART=w.PART_ID, this field is renamed to PART_ID2(i used the sql profiler for tracing). I don't know why after I do the table splitting, then the name is changed.BTW, i have tried other fields, everything is working fine except the column name is same with the join table.

Any help would be appreciated.

peter
  • 1
  • After I tested it. Actually it is not about the join, even I only query the one table, the column name "PART_ID" is still changed to "PART_ID2", other column are fine. – peter Jan 26 '16 at 06:18
  • Are you using Code-First or Db-First approach? If you use Db-First approach, please provide entity configurations for INVENTORY_TRANS and WORK_ORDER entities – Red Jan 26 '16 at 09:20
  • I am using the code-first. And I have fixed this issue already. This is caused by the one to one relationship between entities.Thanks for your response – peter Jan 26 '16 at 12:18

0 Answers0