using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//namespace SE0085.CTdB
namespace FAS_LIB
{
    public class clsEngineCTdB
    {
        public scItemMaster rtnByAssyPartNum(string AssyPart)
        {
            
            scItemMaster scItemMaster = new scItemMaster();
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
        //        se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
        //        ParameterExpression parameterExpression;

        //        // ISSUE: reference to a compiler-generated field
        //        IQueryable<scItemMaster> source = (IQueryable<scItemMaster>)Queryable.Select<AssyPart, scItemMaster>(Queryable.Where<AssyPart>((IQueryable<M0>)se0085CtEntities1.AssyParts, (Expression<Func<M0, bool>>)(p => Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), p.AssyPartNum, closure32.AssyPart, false) == 0)), (Expression<Func<M0, M1>>)Expression.Lambda<Func<AssyPart, scItemMaster>>((Expression)Expression.MemberInit(Expression.New((ConstructorInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.Ector)), (Expression[])null), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_AssyPartId)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_AssyPartId)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_AssyPartNumber)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_AssyPartNum)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_Description1)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_AssyDesc1)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_Description2)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_AssyDesc2)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_BuyMake)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_BuyMake)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_OFOKanban)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_OFOKanban)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_AssyPartActive)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_AssyPartActive)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_CostCode)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_CostCode)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_UOM)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_UOM)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_UnitCost)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_UnitCost))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_MaterialCost)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_MaterialCost))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_LaborCost)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_LaborCost))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_OverHeadCost)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_OveheadCost))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_O08FBUR)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_O08FBUR))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_O09PBUR)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_O09PBUR))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_O10AMU)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_O10AMU))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_O11VBUR)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_O11VBUR))), typeof(Decimal))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_Vendor)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_Vendor)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_Routing)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_Routing)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_ItemType)), (Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_ItemType)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scItemMaster.set_DateAdded)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssyPart.get_DateAdded))), typeof(DateTime)))), new ParameterExpression[1]
        //{
        //  parameterExpression
        //}));
                IQueryable<scItemMaster> source = (from s in se0085CtEntities1.AssyParts
                                                   where string.Equals(s.AssyPartNum, AssyPart)
                                                   select new scItemMaster
                                                   {
                                                       AssyPartId = s.AssyPartId,
                                                       AssyPartNumber = s.AssyPartNum,
                                                       BuyMake = s.BuyMake,
                                                       OFOKanban = s.OFOKanban,
                                                       Description1 = s.AssyDesc1,
                                                       Description2 = s.AssyDesc2,
                                                       AssyPartActive = s.AssyPartActive,
                                                       DateAdded = s.DateAdded.HasValue ? s.DateAdded.Value : DateTime.Now,
                                                       CostCode = s.CostCode,
                                                       UOM =s.UOM,
                                                       UnitCost = s.UnitCost.HasValue ? s.UnitCost.Value : 0,
                                                       LaborCost = s.LaborCost.HasValue ? s.LaborCost.Value : 0,
                                                       MaterialCost = s.MaterialCost.HasValue ? s.MaterialCost.Value : 0,
                                                       OverHeadCost =s.OveheadCost.HasValue ? s.OveheadCost.Value : 0 ,
                                                       O08FBUR = s.O08FBUR.HasValue ? s.O08FBUR.Value : 0,
                                                       O09PBUR = s.O09PBUR.HasValue ? s.O09PBUR.Value : 0,
                                                       O10AMU = s.O10AMU.HasValue ? s.O10AMU.Value : 0,
                                                       O11VBUR = s.O11VBUR.HasValue ? s.O11VBUR.Value : 0,
                                                       Vendor = s.Vendor,
                                                       Routing = s.Routing,
                                                       ItemType = s.ItemType
                                                   }).AsQueryable<scItemMaster>();
                if (source.Count<scItemMaster>() == 1)
                    scItemMaster = source.First<scItemMaster>();
                se0085CtEntities1.Database.Connection.Close();
            }
            return scItemMaster;
        }

        public int rtnOrderLineId(string FOLineSLSS)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            //clsEngineCTdB closure2 = new clsEngineCTdB();
            //// ISSUE: reference to a compiler-generated field
            scOrderData ldOrder = new scOrderData();
            ldOrder.FactoryOrder = FOLineSLSS;
            int num = 0;
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
                //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;                
                //IQueryable<int> source = (IQueryable<int>)Queryable.Select(Queryable.Where((IQueryable<M0>)Queryable.Join((IQueryable<M0>)Queryable.Join((IQueryable<M0>)Queryable.Join((IQueryable<M0>)se0085CtEntities1.SEOrders, (IEnumerable<M1>)se0085CtEntities1.OrderLines, (Expression<Func<M0, M2>>)(od => od.OrderId), (Expression<Func<M1, M2>>)(ol => ol.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>)((od, ol) => new { od = od, ol = ol })), (IEnumerable<M1>)se0085CtEntities1.AssemblyLines, (Expression<Func<M0, M2>>)(data => data.ol.AssemblyLine.AssemLineId), (Expression<Func<M1, M2>>)(al => al.AssemLineId), (Expression<Func<M0, M1, M3>>)((data, al) => new
                //{
                //    It1 = data,
                //    al = al
                //})), (IEnumerable<M1>)se0085CtEntities1.SEPlants, (Expression<Func<M0, M2>>)(data => data.al.SEPlant.SEPlantId), (Expression<Func<M1, M2>>)(pl => pl.SEPlantId), (Expression<Func<M0, M1, M3>>)((data, pl) => new
                //{
                //    od = data.It1.od,
                //    ol = data.It1.ol,
                //    al = data.al,
                //    pl = pl
                //})), (Expression<Func<M0, bool>>)(data => Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), data.od.OrderFO, closure2.ldOrder.OrderFO, false) == 0 & Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), data.ol.OrderLineNum, closure2.ldOrder.OrderLineNum, false) == 0 & Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), data.ol.OrderLineSL, closure2.ldOrder.OrderLineSL, false) == 0 & Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), data.ol.OrderLineSS, closure2.ldOrder.OrderLineSS, false) == 0)), (Expression<Func<M0, M1>>)(data => data.ol.OrderLineId));

                //EXTRA CODE .
                //38090312 001 0001
                //38575365 004 0001
                //38671194 001 0001
                //38777183 006 0001
                //29868638 224 0001
                //DOUBT
                IQueryable<int> source = from od in se0085CtEntities1.SEOrders
                            join ol in se0085CtEntities1.OrderLines
                            on od.OrderId equals ol.SEOrder.OrderId
                            join al in se0085CtEntities1.AssemblyLines
                            on ol.AssemblyLine.AssemLineId equals al.AssemLineId
                            join pl in se0085CtEntities1.SEPlants
                            on al.SEPlant.SEPlantId equals pl.SEPlantId
                            where string.Equals(od.OrderFO,ldOrder.OrderFO)
                            && string.Equals(ol.OrderLineNum,ldOrder.OrderLineNum)
                            && string.Equals(ol.OrderLineSL,ldOrder.OrderLineSL)
                            && string.Equals(ol.OrderLineSS,ldOrder.OrderLineSS)
                            select ol.OrderLineId;

                if (source != null && source.Count<int>() > 0)
                    num = source.First<int>();
                se0085CtEntities1.Database.Connection.Close();
            }
            return num;
        }

        public bool AddUpdFASDtlByMO(string MO)
        {
            int ldSect = 0;//FORECEFULLY DECLARED TO REMOVE ERROR
			List<scOrdFASInfo>.Enumerator enumerator = new List<scOrdFASInfo>.Enumerator();
			List<scMESBOM>.Enumerator enumerator1 = new List<scMESBOM>.Enumerator();
			bool? nullable;
			decimal? nullable1;
			bool? nullable2;
			double? nullable3;
			bool? nullable4;
			bool? nullable5;
			bool? nullable6;
			int ordFASExtId = 0;
			bool ldResult = true;
			List<scOrdFASInfo> ldOrder = new List<scOrdFASInfo>();
			if (MO.Length > 0)
			{
				using (SE0085CTEntities1 CTdB = new SE0085CTEntities1())
				{
                    //IQueryable<scOrdFASInfo> source1 = (IQueryable<scOrdFASInfo>)Queryable.Select(Queryable.Where((IQueryable<M0>)Queryable.Join((IQueryable<M0>)Queryable.Join((IQueryable<M0>)Queryable.Join((IQueryable<M0>)se0085CtEntities1.SEOrders, (IEnumerable<M1>)se0085CtEntities1.OrderLines, (Expression<Func<M0, M2>>)(od => od.OrderId), (Expression<Func<M1, M2>>)(ol => ol.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>)((od, ol) => new { od = od, ol = ol })), (IEnumerable<M1>)se0085CtEntities1.AssemblyLines, (Expression<Func<M0, M2>>)(data => data.ol.AssemblyLine.AssemLineId), (Expression<Func<M1, M2>>)(al => al.AssemLineId), (Expression<Func<M0, M1, M3>>)((data, al) => new
                    //{
                    //    It1 = data,
                    //    al = al
                    //})), (IEnumerable<M1>)se0085CtEntities1.OrdFASExts, (Expression<Func<M0, M2>>)(data => data.It1.ol.OrderLineId), (Expression<Func<M1, M2>>)(fe => fe.OrderLine.OrderLineId), (Expression<Func<M0, M1, M3>>)((data, fe) => new
                    //{
                    //    od = data.It1.od,
                    //    ol = data.It1.ol,
                    //    al = data.al,
                    //    fe = fe
                    //})), (Expression<Func<M0, bool>>)(data => Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), data.fe.FASOrdNbr, closure16.MO, false) == 0)), (Expression<Func<M0, M1>>)Expression.Lambda<Func<AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>, scOrdFASInfo>>((Expression)Expression.MemberInit(Expression.New((ConstructorInfo)MethodBase.GetMethodFromHandle(__methodref(scOrdFASInfo.ctor)), (Expression[])null), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_AssemblyLineId)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_al), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssemblyLine.get_AssemLineId)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_AssemLineAbbrv)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_al), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AssemblyLine.get_AssemLineAbbrv)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderId)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_od), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(SEOrder.get_OrderId)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderFO)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_od), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(SEOrder.get_OrderFO)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderJobName)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_od), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(SEOrder.get_OrderJobName)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineId)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineId)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineNum)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineNum)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineSL)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineSL)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineSS)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineSS)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineTargetDt)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineTargetDt))), typeof(DateTime))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineShipDt)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineShipDt))), typeof(DateTime))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrderData.set_OrderLineAssyStartDt)), (Expression)Expression.Convert((Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_ol), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrderLine.get_OrderLineAssyStartDt))), typeof(DateTime))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrdFASInfo.set_OrdMfgPartNbr)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_fe), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdFASExt.get_OrdMfgPartNbr)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrdFASInfo.set_OrdFASExtId)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_fe), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdFASExt.get_OrdFASExtId)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrdFASInfo.set_FASOrdNbr)), (Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_fe), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdFASExt.get_FASOrdNbr)))), (MemberBinding)Expression.Bind((MethodInfo)MethodBase.GetMethodFromHandle(__methodref(scOrdFASInfo.set_FASOrdQty)), (Expression)Expression.ConvertChecked((Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression1, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>.get_fe), __typeref(AnonymousType_7<SEOrder, OrderLine, AssemblyLine, OrdFASExt>))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdFASExt.get_FASOrdQty))), typeof(int)))), new ParameterExpression[1]
                    //{
                    //    parameterExpression1
                    //}));
                    IQueryable<scOrdFASInfo> ldOrderQuery = (from od in CTdB.SEOrders
                                                        join ol in CTdB.OrderLines
                                                        on od.OrderId equals ol.SEOrder.OrderId
                                                        join al in CTdB.AssemblyLines
                                                        on ol.AssemblyLine.AssemLineId equals al.AssemLineId
                                                        join fe in CTdB.OrdFASExts
                                                        on ol.OrderLineId equals fe.OrderLine.OrderLineId
                                                        where string.Equals(fe.FASOrdNbr, MO)
                                                        select new scOrdFASInfo
                                                        {
                                                            AssemblyLineId = al.AssemLineId,
                                                            AssemLineAbbrv = al.AssemLineAbbrv,
                                                            OrderId = od.OrderId,
                                                            OrderFO = od.OrderFO,
                                                            OrderJobName = od.OrderJobName,
                                                            OrderLineId = ol.OrderLineId,
                                                            OrderLineNum = ol.OrderLineNum,
                                                            OrderLineSL = ol.OrderLineSL,
                                                            OrderLineSS = ol.OrderLineSS,
                                                            OrderLineTargetDt = ol.OrderLineTargetDt.HasValue ? ol.OrderLineTargetDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineShipDt = ol.OrderLineShipDt.HasValue ? ol.OrderLineShipDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineAssyStartDt = ol.OrderLineAssyStartDt.HasValue ? ol.OrderLineAssyStartDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrdMfgPartNbr = fe.OrdMfgPartNbr,
                                                            OrdFASExtDtlId = fe.OrdFASExtId,
                                                            FASOrdNbr = fe.FASOrdNbr,
                                                            FASOrdQty = fe.FASOrdQty.HasValue ? fe.FASOrdQty.Value : 0
                                                        }).AsQueryable<scOrdFASInfo>();
					if (ldOrderQuery != null)
					{
						if (ldOrderQuery.Count<scOrdFASInfo>() > 0)
						{
							ldOrder = ldOrderQuery.ToList<scOrdFASInfo>();
							clsEngineMES lcMES = new clsEngineMES();
							OrdFASExt ordFASExt = new OrdFASExt();
							try
							{
								enumerator = ldOrder.GetEnumerator();
								while (enumerator.MoveNext())
								{
									scOrdFASInfo ldData = enumerator.Current;
									int ldOrdLineId = ldData.OrderLineId;
									if (ldData.OrdFASExtId != ordFASExtId)
									{
										ordFASExtId = ldData.OrdFASExtId;
                                        //    IQueryable<OrdFASExt> source2 = (IQueryable<OrdFASExt>)Queryable.Select<OrdFASExt, OrdFASExt>(Queryable.Where<OrdFASExt>((IQueryable<M0>)se0085CtEntities1.OrdFASExts, (Expression<Func<M0, bool>>)Expression.Lambda<Func<OrdFASExt, bool>>((Expression)Expression.Equal(fe.OrdFASExtId, closure17.ldOrdFASExtId, true, (MethodInfo)null), new ParameterExpression[1]
                                        //      {
                                        //        parameterExpression2
                                        //      })), (Expression<Func<M0, M1>>)(fe => fe));

                                        IQueryable<OrdFASExt> ldQryFASExt = (from fe in CTdB.OrdFASExts
                                                                            where fe.OrdFASExtId == ordFASExtId
                                                                            select fe).AsQueryable<OrdFASExt>();
										if (ldQryFASExt != null)
										{
											ordFASExt = ldQryFASExt.First<OrdFASExt>();
										}
									}
                                    List<scMESBOM> ldBOM = new List<scMESBOM>();
                                    ldBOM = lcMES.rtnNWLocation(ldData.OrderFO, ldData.OrderLineNum, ldData.OrderLineSL, ldData.OrderLineSS, ldData.OrdMfgPartNbr);
                                    if (ldBOM.Count == 0)
                                    {
                                        ldResult = false;
                                    }
                                    OrdSection ldOrdSect = new OrdSection();
									try
									{
										enumerator1 = ldBOM.GetEnumerator();
										while (enumerator1.MoveNext())
										{
											scMESBOM ldMOSect = enumerator1.Current;
											if (Conversions.ToInteger(ldMOSect.sect_id) != ldSect)
											{
												ldSect = Conversions.ToInteger(ldMOSect.sect_id);

                                                //IQueryable<OrdSection> source2 = (IQueryable<OrdSection>)Queryable.Select<OrdSection, OrdSection>(Queryable.Where<OrdSection>((IQueryable<M0>)se0085CtEntities1.OrdSections, (Expression<Func<M0, bool>>)Expression.Lambda<Func<OrdSection, bool>>((Expression)Expression.And((Expression)Expression.Equal(s.OrderLine.OrderLineId, other.ldOrdLineId, true, (MethodInfo)null), (Expression)Expression.Equal((Expression)Expression.Property((Expression)parameterExpression2, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdSection.get_OrdSectsNum))), (Expression)Expression.Field((Expression)Expression.Constant((object)other, typeof(clsEngineCTdB)), FieldInfo.GetFieldFromHandle(__fieldref(clsEngineCTdB.ldSect))), true, (MethodInfo)null)), new ParameterExpression[1]
                                                //  {
                                                //    parameterExpression2
                                                //  })), (Expression<Func<M0, M1>>)(s => s));
                                                IQueryable<OrdSection> ldQrySect = (from s in CTdB.OrdSections
                                                                                  where s.OrderLine.OrderLineId == ldOrdLineId
                                                                                  select s).AsQueryable<OrdSection>();

												if (ldQrySect != null)
												{
													if (ldQrySect.Count<OrdSection>() > 0)
													{
														ldOrdSect = ldQrySect.First<OrdSection>();

                                                        //IQueryable<OrdFASExtDtl> source3 = (IQueryable<OrdFASExtDtl>)Queryable.Select<OrdFASExtDtl, OrdFASExtDtl>(Queryable.Where<OrdFASExtDtl>((IQueryable<M0>)se0085CtEntities1.OrdFASExtDtls, (Expression<Func<M0, bool>>)Expression.Lambda<Func<OrdFASExtDtl, bool>>((Expression)Expression.And((Expression)Expression.Equal(dt.OrdFASExt.OrdFASExtId, closure17.ldOrdFASExt.OrdFASExtId, true, (MethodInfo)null), (Expression)Expression.Equal((Expression)Expression.Property((Expression)Expression.Property((Expression)parameterExpression3, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdFASExtDtl.get_OrdSection))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdSection.get_OrdSectsId))), (Expression)Expression.Property((Expression)Expression.Field((Expression)Expression.Constant((object)other, typeof(clsEngineCTdB)), FieldInfo.GetFieldFromHandle(__fieldref(clsEngineCTdB.ldOrdSect))), (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(OrdSection.get_OrdSectsId))), true, (MethodInfo)null)), new ParameterExpression[1]
                                                        //{
                                                        //  parameterExpression3
                                                        //})), (Expression<Func<M0, M1>>)(dt => dt));
                                                        IQueryable<OrdFASExtDtl> ldQry = from dt in CTdB.OrdFASExtDtls
                                                                                   where dt.OrdFASExt.OrdFASExtId == ordFASExt.OrdFASExtId
                                                                                   select dt;
														bool ldAddMO2Sect = true;
														OrdFASExtDtl ldOrdFASExtDtl = new OrdFASExtDtl();
														if (ldQry != null)
														{
															if (ldQry.Count<OrdFASExtDtl>() == 1)
															{
																ldOrdFASExtDtl = ldQry.First<OrdFASExtDtl>();
																decimal extQtyPer = ldMOSect.ext_qty_per;
																int? ordBldReqSectQty = ldOrdFASExtDtl.OrdBldReqSectQty;
																if (ordBldReqSectQty.HasValue)
																{
																	nullable1 = new decimal?(new decimal(ordBldReqSectQty.GetValueOrDefault()));
																}
																else
																{
																	nullable1 = null;
																}
																decimal? nullable7 = nullable1;
																if (nullable7.HasValue)
																{
																	bool? nullable8 = new bool?(decimal.Compare(nullable7.GetValueOrDefault(), extQtyPer) == 0);
																	nullable2 = nullable8;
																}
																else
																{
																	nullable = null;
																	nullable2 = nullable;
																}
																bool? nullable9 = nullable2;
																double num = Conversions.ToDouble(ldMOSect.shp_splt);
																int? ordBldReqShipSpt = ldOrdFASExtDtl.OrdBldReqShipSpt;
																if (ordBldReqShipSpt.HasValue)
																{
																	nullable3 = new double?((double)ordBldReqShipSpt.GetValueOrDefault());
																}
																else
																{
																	nullable3 = null;
																}
																double? nullable10 = nullable3;
																if (nullable10.HasValue)
																{
																	nullable4 = new bool?(nullable10.GetValueOrDefault() == num);
																}
																else
																{
																	nullable = null;
																	nullable4 = nullable;
																}
																bool? nullable11 = nullable4;
																if (nullable9.HasValue && !nullable9.GetValueOrDefault())
																{
																	nullable5 = new bool?(false);
																}
																else if (nullable11.HasValue)
																{
																	nullable5 = (nullable11.GetValueOrDefault() ? nullable9 : new bool?(false));
																}
																else
																{
																	nullable = null;
																	nullable5 = nullable;
																}
																bool? nullable12 = nullable5;
																if (nullable12.HasValue)
																{
																	nullable6 = new bool?(!nullable12.GetValueOrDefault());
																}
																else
																{
																	nullable = null;
																	nullable6 = nullable;
																}
																if (nullable6.GetValueOrDefault())
																{
																	ldOrdFASExtDtl.OrdBldReqSectQty = Convert.ToInt32(ldMOSect.ext_qty_per);
																	ldOrdFASExtDtl.OrdBldReqShipSpt = Conversions.ToInteger(ldMOSect.shp_splt);
																	if (CTdB.SaveChanges() == 0)
																	{
																		ldResult = false;
																	}
																}
																ldAddMO2Sect = false;
															}
														}
														if (ldAddMO2Sect)
														{
															ldOrdFASExtDtl.OrdFASExt = ordFASExt;
															ldOrdFASExtDtl.OrdSection = ldOrdSect;
															ldOrdFASExtDtl.OrdBldRequest = false;
															ldOrdFASExtDtl.OrdBldRequestedDt = Conversions.ToDate("01/01/1901");
															ldOrdFASExtDtl.OrdBldRequiredDt = Conversions.ToDate("01/01/1901");
															ldOrdFASExtDtl.OrdBldCompleteDt = Conversions.ToDate("01/01/1901");
															ldOrdFASExtDtl.OrdBldReqSectQty = Convert.ToInt32(ldMOSect.ext_qty_per);
															ldOrdFASExtDtl.OrdBldReqShipSpt = Conversions.ToInteger(ldMOSect.shp_splt);
															CTdB.OrdFASExtDtls.Add(ldOrdFASExtDtl);
															if (CTdB.SaveChanges() == 0)
															{
																ldResult = false;
															}
														}
													}
												}
											}
										}
									}
									finally
									{
										((IDisposable)enumerator1).Dispose();
									}
								}
							}
							finally
							{
								((IDisposable)enumerator).Dispose();
							}
						}
					}
				}
			}
			return ldResult;
        }

       
        public List<scOrderData> rtnOVDataAllOpen(string AssemblyLine, DateTime ShipDateStart, DateTime ShipDateEnd)
        {
          List<scOrderData> scOrderDataList = new List<scOrderData>();
          using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
          {
            //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
            //ParameterExpression parameterExpression1;
            //ParameterExpression parameterExpression2;
            //IQueryable<scOrderData> source = (IQueryable<scOrderData>) Queryable.Select((IQueryable<M0>) Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.OrderBy(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.SEOrders.Distinct<SEOrder>(), (IEnumerable<M1>) se0085CtEntities1.OrderLines.Distinct<OrderLine>(), (Expression<Func<M0, M2>>) (od => od.OrderId), (Expression<Func<M1, M2>>) (ol => ol.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>) ((od, ol) => new{ od = od, ol = ol })), (IEnumerable<M1>) se0085CtEntities1.AssemblyLines, (Expression<Func<M0, M2>>) (data => data.ol.AssemblyLine.AssemLineId), (Expression<Func<M1, M2>>) (al => al.AssemLineId), (Expression<Func<M0, M1, M3>>) ((data, al) => new
            //{
            //  \u0024VB\u0024It1 = data,
            //  al = al
            //})), (IEnumerable<M1>) se0085CtEntities1.SEPlants, (Expression<Func<M0, M2>>) (data => data.al.SEPlant.SEPlantId), (Expression<Func<M1, M2>>) (pl => pl.SEPlantId), (Expression<Func<M0, M1, M3>>) ((data, pl) => new
            //{
            //  od = data.\u0024VB\u0024It1.od,
            //  ol = data.\u0024VB\u0024It1.ol,
            //  al = data.al,
            //  pl = pl
            //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>, bool>>((Expression) Expression.Coalesce((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(\u0024VB\u0024It.ol.OrderLineShipped, (bool?) false, true, (MethodInfo) null), (Expression) Expression.Convert((Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_al), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineAbbrv))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure7, typeof (clsEngineCTdB._Closure\u0024__7)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__7.\u0024VB\u0024Local_AssemblyLine))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int))), typeof (bool?))), (Expression) Expression.GreaterThanOrEqual((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure7, typeof (clsEngineCTdB._Closure\u0024__7)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__7.\u0024VB\u0024Local_ShipDateStart))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_GreaterThanOrEqual)))), (Expression) Expression.LessThanOrEqual((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure7, typeof (clsEngineCTdB._Closure\u0024__7)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__7.\u0024VB\u0024Local_ShipDateEnd))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThanOrEqual)))), (Expression) Expression.Constant((object) false, typeof (bool))), new ParameterExpression[1]
            //{
            //  parameterExpression1
            //})), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineShipDt)), (Expression<Func<M0, M1>>) (data => data.od.OrderFO)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineNum)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineSL)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineSS)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>, scOrderData>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_AssemblyLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_al), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_AssemLineAbbrv)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_al), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineAbbrv)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_od), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderFO)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_od), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderFO)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderJobName)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_od), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderJobName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderLineNum)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineNum)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderLineSL)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSL)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderLineSS)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSS)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderLineShipDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderData.set_OrderLineAssyStartDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>.get_ol), __typeref (VB\u0024AnonymousType_2<SEOrder, OrderLine, AssemblyLine, SEPlant>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineAssyStartDt))), typeof (DateTime)))), new ParameterExpression[1]
            //{
            //  parameterExpression2
            //}));
            IQueryable<scOrderData> source = (from od in se0085CtEntities1.SEOrders.Distinct()
                                             join ol in se0085CtEntities1.OrderLines.Distinct()
                                             on od.OrderId equals ol.SEOrder.OrderId
                                             join al in se0085CtEntities1.AssemblyLines
                                             on ol.AssemblyLine.AssemLineId equals al.AssemLineId
                                             join sp in se0085CtEntities1.SEPlants
                                             on al.SEPlant.SEPlantId equals sp.SEPlantId
                                             where al.AssemLineAbbrv == AssemblyLine
                                             && ol.OrderLineShipDt >= ShipDateStart
                                             && ol.OrderLineShipDt <= ShipDateEnd
                                             orderby ol.OrderLineShipDt,od.OrderFO,ol.OrderLineNum,ol.OrderLineSL,ol.OrderLineSS
                                             select new scOrderData
                                             {
                                                 AssemblyLineId = al.AssemLineId,
                                                 AssemLineAbbrv = al.AssemLineAbbrv,
                                                 OrderId = od.OrderId,
                                                 OrderFO = od.OrderFO,
                                                 OrderJobName = od.OrderJobName,
                                                 OrderLineId = ol.OrderLineId,
                                                 OrderLineNum = ol.OrderLineNum,
                                                 OrderLineSL = ol.OrderLineSL,
                                                 OrderLineSS = ol.OrderLineSS,
                                                 OrderLineShipDt = ol.OrderLineShipDt.HasValue ? ol.OrderLineShipDt.Value : Conversions.ToDate("01/01/1901"),
                                                 OrderLineAssyStartDt = ol.OrderLineAssyStartDt.HasValue ? ol.OrderLineAssyStartDt.Value : Conversions.ToDate("01/01/1901")
                                             }).AsQueryable<scOrderData>();
            if (source != null && source.Count<scOrderData>() > 0)
              scOrderDataList = source.ToList<scOrderData>();
            se0085CtEntities1.Database.Connection.Close();
          }
          return scOrderDataList;
        }

        public List<scOrderImportInfo> rtnEngrOrderStatus(string AssemblyLine, DateTime ReleaseDtStart, DateTime ReleaseDtEnd)
        {
          // ISSUE: object of a compiler-generated type is created
          // ISSUE: variable of a compiler-generated type
          //clsEngineCTdB._Closure\u0024__48 closure48 = new clsEngineCTdB._Closure\u0024__48();
          // ISSUE: reference to a compiler-generated field
          //closure48.\u0024VB\u0024Local_ReleaseDtStart = ReleaseDtStart;
          // ISSUE: reference to a compiler-generated field
          //closure48.\u0024VB\u0024Local_ReleaseDtEnd = ReleaseDtEnd;
          // ISSUE: reference to a compiler-generated field
          //closure48.\u0024VB\u0024Local_AssemblyLine = AssemblyLine;
          List<scOrderImportInfo> scOrderImportInfoList = new List<scOrderImportInfo>();
          //if (true)
          //{
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
              //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
              //ParameterExpression parameterExpression1;
              //ParameterExpression parameterExpression2;
              //IQueryable<scOrderImportInfo> source = (IQueryable<scOrderImportInfo>) Queryable.Select((IQueryable<M0>) Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.OrderBy(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.SEOrders.Distinct<SEOrder>(), (IEnumerable<M1>) se0085CtEntities1.OrderLines.Distinct<OrderLine>(), (Expression<Func<M0, M2>>) (od => od.OrderId), (Expression<Func<M1, M2>>) (ol => ol.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>) ((od, ol) => new{ od = od, ol = ol })), (IEnumerable<M1>) se0085CtEntities1.AssemblyLines, (Expression<Func<M0, M2>>) (data => data.ol.AssemblyLine.AssemLineId), (Expression<Func<M1, M2>>) (al => al.AssemLineId), (Expression<Func<M0, M1, M3>>) ((data, al) => new
              //{
              //  \u0024VB\u0024It1 = data,
              //  al = al
              //})), (IEnumerable<M1>) se0085CtEntities1.SEPlants, (Expression<Func<M0, M2>>) (data => data.al.SEPlant.SEPlantId), (Expression<Func<M1, M2>>) (pl => pl.SEPlantId), (Expression<Func<M0, M1, M3>>) ((data, pl) => new
              //{
              //  \u0024VB\u0024It1 = data,
              //  pl = pl
              //})), (IEnumerable<M1>) se0085CtEntities1.OrderLinesExts, (Expression<Func<M0, M2>>) (data => data.\u0024VB\u0024It1.\u0024VB\u0024It1.ol.OrderLineId), (Expression<Func<M1, M2>>) (oe => oe.OrderLine.OrderLineId), (Expression<Func<M0, M1, M3>>) ((data, oe) => new
              //{
              //  od = data.\u0024VB\u0024It1.\u0024VB\u0024It1.od,
              //  ol = data.\u0024VB\u0024It1.\u0024VB\u0024It1.ol,
              //  al = data.\u0024VB\u0024It1.al,
              //  pl = data.pl,
              //  oe = oe
              //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>, bool>>((Expression) Expression.Coalesce((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(\u0024VB\u0024It.ol.OrderLineShipped, (bool?) false, true, (MethodInfo) null), (Expression) Expression.Convert((Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_al), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineAbbrv))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure48, typeof (clsEngineCTdB._Closure\u0024__48)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__48.\u0024VB\u0024Local_AssemblyLine))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int))), typeof (bool?))), (Expression) Expression.GreaterThanOrEqual((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgEngrRelDt))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure48, typeof (clsEngineCTdB._Closure\u0024__48)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__48.\u0024VB\u0024Local_ReleaseDtStart))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_GreaterThanOrEqual)))), (Expression) Expression.LessThanOrEqual((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgEngrRelDt))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure48, typeof (clsEngineCTdB._Closure\u0024__48)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__48.\u0024VB\u0024Local_ReleaseDtEnd))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThanOrEqual)))), (Expression) Expression.LessThan((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), (Expression) Expression.Convert((Expression) Expression.Convert((Expression) Expression.Constant((object) "12-31-2020", typeof (string)), typeof (DateTime), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Conversions.ToDate))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThan)))), (Expression) Expression.Constant((object) false, typeof (bool))), new ParameterExpression[1]
              //{
              //  parameterExpression1
              //})), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineTargetDt)), (Expression<Func<M0, M1>>) (data => data.oe.OrderLineOrgShipDt)), (Expression<Func<M0, M1>>) (data => data.od.OrderFO)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineNum)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineSL)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineSS)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>, scOrderImportInfo>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_SEPlantId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_pl), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEPlant.get_SEPlantId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_AssemblyLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_al), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_od), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderFO)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_od), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderFO)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderJobName)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_od), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderJobName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineNum)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineNum)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineSL)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSL)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineSS)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSS)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineTargetDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineTargetDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineShipDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineExtId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineExtId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineSER)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSER)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineBook)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineBook))), typeof (Decimal))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineNet)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineNet))), typeof (Decimal))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgTargetDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgTargetDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgShipDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgShipDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgAssyStDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgAssyStDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineCurAssyStDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineCurAssyStDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineActAssyStDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineActAssyStDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgEngrRelDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgEngrRelDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineCurEngrRelDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineCurEngrRelDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineActEngrRelDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineActEngrRelDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineNB4Dt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineNB4Dt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineEngrGrp)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineEngrGrp)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineMechClpx)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineMechClpx)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineElecClpx)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineElecClpx)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineEngComposite)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineEngComposite))), typeof (long))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLinePeltCode)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLinePeltCode))))), new ParameterExpression[1]
              //{
              //  parameterExpression2
              //}));

                IQueryable<scOrderImportInfo> source = (from od in se0085CtEntities1.SEOrders.Distinct()
                                                        join ol in se0085CtEntities1.OrderLines.Distinct()
                                                        on od.OrderId equals ol.SEOrder.OrderId
                                                        join al in se0085CtEntities1.AssemblyLines
                                                        on ol.AssemblyLine.AssemLineId equals al.AssemLineId
                                                        join pl in se0085CtEntities1.SEPlants
                                                        on al.SEPlant.SEPlantId equals pl.SEPlantId
                                                        join oe in se0085CtEntities1.OrderLinesExts
                                                        on ol.OrderLineId equals oe.OrderLine.OrderLineId
                                                        where al.AssemLineAbbrv == AssemblyLine
                                                        && oe.OrderLineOrgEngrRelDt >= ReleaseDtStart
                                                        && oe.OrderLineOrgEngrRelDt <= ReleaseDtEnd
                                                        orderby ol.OrderLineTargetDt, oe.OrderLineOrgShipDt, od.OrderFO, ol.OrderLineNum, ol.OrderLineSL, ol.OrderLineSS
                                                        select new scOrderImportInfo
                                                        {
                                                            OrderLineTargetDt = ol.OrderLineTargetDt.HasValue ? ol.OrderLineTargetDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineOrgShipDt = oe.OrderLineOrgShipDt.HasValue ? oe.OrderLineOrgShipDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderFO = od.OrderFO,
                                                            OrderLineNum = ol.OrderLineNum,
                                                            OrderLineSL = ol.OrderLineSL,
                                                            OrderLineSS = ol.OrderLineSS,
                                                            SEPlantId = pl.SEPlantId,
                                                            AssemblyLineId = al.AssemLineId,
                                                            OrderId = od.OrderId,
                                                            OrderJobName = od.OrderJobName,
                                                            OrderLineId = ol.OrderLineId,
                                                            OrderLineShipDt = ol.OrderLineShipDt.HasValue ? ol.OrderLineShipDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineExtId = oe.OrderLineExtId,
                                                            OrderLineSER = ol.OrderLineSER,
                                                            OrderLineBook = oe.OrderLineBook.HasValue ? oe.OrderLineBook.Value : new Decimal(),
                                                            OrderLineNet = oe.OrderLineNet.HasValue ? oe.OrderLineNet.Value : new Decimal(),
                                                            OrderLineOrgTargetDt = oe.OrderLineOrgTargetDt.HasValue ? oe.OrderLineOrgTargetDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineOrgAssyStDt = oe.OrderLineOrgAssyStDt.HasValue ? oe.OrderLineOrgAssyStDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineCurAssyStDt = oe.OrderLineCurAssyStDt.HasValue ? oe.OrderLineCurAssyStDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineActAssyStDt = oe.OrderLineActAssyStDt.HasValue ? oe.OrderLineActAssyStDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineOrgEngrRelDt = oe.OrderLineOrgEngrRelDt.HasValue ? oe.OrderLineOrgEngrRelDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineCurEngrRelDt = oe.OrderLineCurEngrRelDt.HasValue ? oe.OrderLineCurEngrRelDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineActEngrRelDt = oe.OrderLineActEngrRelDt.HasValue ? oe.OrderLineActEngrRelDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineNB4Dt = oe.OrderLineNB4Dt.HasValue ? oe.OrderLineNB4Dt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineEngrGrp = oe.OrderLineEngrGrp,
                                                            OrderLineMechClpx = oe.OrderLineMechClpx,
                                                            OrderLineElecClpx = oe.OrderLineElecClpx,
                                                            OrderLineEngComposite = oe.OrderLineEngComposite.HasValue ? oe.OrderLineEngComposite.Value : 0,
                                                            OrderLinePeltCode = oe.OrderLinePeltCode
                                                        }).AsQueryable<scOrderImportInfo>();
              if (source != null && source.Count<scOrderImportInfo>() > 0)
              {
                scOrderImportInfoList = source.ToList<scOrderImportInfo>();
                clsPlant clsPlant = new clsPlant();
                scPlants scPlants = new scPlants();
                scPlants Plant = clsPlant.rtnPlantById(scOrderImportInfoList[0].SEPlantId);
                clsAssemblyLine clsAssemblyLine = new clsAssemblyLine(Plant);
                List<scOrderImportInfo>.Enumerator enumerator;
                enumerator = scOrderImportInfoList.GetEnumerator();
                try
                {
                  while (enumerator.MoveNext())
                  {
                    scOrderImportInfo current = enumerator.Current;
                    current.SEPlant = Plant;
                    current.AssemblyLine = (scLevels) clsAssemblyLine.rtnAssemblyLineById(current.AssemblyLineId);
                    current.OrderLineOE = this.rtnOrderLineAssocAssign(current.OrderLineId, emOLAssignType.OrderEngr);
                    current.OrderLineME = this.rtnOrderLineAssocAssign(current.OrderLineId, emOLAssignType.MechEngr);
                    current.OrderComments = this.rtnOrderLineComments(current.OrderLineId);
                    current.OrderStatus = this.rtnOrderLineStatus(current.OrderLineId, 0);
                  }
                }
                finally
                {
                  enumerator.Dispose();
                }
              }
              se0085CtEntities1.Database.Connection.Close();
            }
          //}
          return scOrderImportInfoList;
        }

        public scAssociateData rtnOrderLineAssocAssign(int OrderLineId, emOLAssignType AssignType)
        {
          // ISSUE: object of a compiler-generated type is created
          // ISSUE: variable of a compiler-generated type
          //clsEngineCTdB._Closure\u0024__13 closure13 = new clsEngineCTdB._Closure\u0024__13();
          // ISSUE: reference to a compiler-generated field
          //closure13.\u0024VB\u0024Local_OrderLineId = OrderLineId;
          scAssociateData scAssociateData = new scAssociateData();
          // ISSUE: reference to a compiler-generated field
          int ldAssignType = (int) AssignType;
          // ISSUE: reference to a compiler-generated field
          if (OrderLineId > 0)
          {
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
              //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
              //ParameterExpression parameterExpression1;
              //ParameterExpression parameterExpression2;
              //IQueryable<scAssociateData> source = (IQueryable<scAssociateData>) Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.OrdLineAssocAssigneds, (IEnumerable<M1>) se0085CtEntities1.Associates, (Expression<Func<M0, M2>>) (p => p.Associate.AssocId), (Expression<Func<M1, M2>>) (a => a.AssocId), (Expression<Func<M0, M1, M3>>) ((p, a) => new{ p = p, a = a })), (IEnumerable<M1>) se0085CtEntities1.AssocAssignTypes, (Expression<Func<M0, M2>>) (data => data.p.AssocAssignType.AssocAssignTypeId), (Expression<Func<M1, M2>>) (t => t.AssocAssignTypeId), (Expression<Func<M0, M1, M3>>) ((data, t) => new
              //{
              //  p = data.p,
              //  a = data.a,
              //  t = t
              //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>, bool>>((Expression) Expression.And((Expression) Expression.Equal(\u0024VB\u0024It.p.OrderLine.OrderLineId, closure13.\u0024VB\u0024Local_OrderLineId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_t), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeValue))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure13, typeof (clsEngineCTdB._Closure\u0024__13)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__13.\u0024VB\u0024Local_ldAssignType))), true, (MethodInfo) null)), new ParameterExpression[1]
              //{
              //  parameterExpression1
              //})), (Expression<Func<M0, M1>>) Expression.Lambda<Func<VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>, scAssociateData>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocEmpId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocEmpId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocLaborName)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocLaborName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocFirstName)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocFirstName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocLastName)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocLastName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocLogin)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocLogin)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocSESA)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocSESA)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocEmail)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocEmail)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocQCInsp)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocQCInsp))), typeof (bool))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocUserPriv)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocUserPriv))), typeof (long))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocPhone)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocPhone)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocExt)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocExt)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scAssociateData.set_AssocActive)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>.get_a), __typeref (VB\u0024AnonymousType_6<OrdLineAssocAssigned, Associate, AssocAssignType>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocActive))), typeof (bool)))), new ParameterExpression[1]
              //{
              //  parameterExpression2
              //}));
                IQueryable<scAssociateData> source = (from p in se0085CtEntities1.OrdLineAssocAssigneds
                                                      join a in se0085CtEntities1.Associates
                                                      on p.Associate.AssocId equals a.AssocId
                                                      join t in se0085CtEntities1.AssocAssignTypes
                                                      on p.AssocAssignType.AssocAssignTypeId equals t.AssocAssignTypeId
                                                      where p.OrderLine.OrderLineId == OrderLineId
                                                      && t.AssocAssignTypeValue == ldAssignType
                                                      select new scAssociateData
                                                      {
                                                          AssocId = a.AssocId,
                                                          AssocEmpId = a.AssocEmpId,
                                                          AssocLaborName = a.AssocLaborName,
                                                          AssocFirstName = a.AssocFirstName,
                                                          AssocLastName = a.AssocLastName,
                                                          AssocLogin = a.AssocLogin,
                                                          AssocSESA = a.AssocSESA,
                                                          AssocEmail = a.AssocEmail,
                                                          AssocQCInsp = a.AssocQCInsp.HasValue ? a.AssocQCInsp.Value : false,
                                                          AssocUserPriv = a.AssocUserPriv.HasValue ? a.AssocUserPriv.Value : 0,
                                                          AssocPhone = a.AssocPhone,
                                                          AssocExt = a.AssocExt,
                                                          AssocActive = a.AssocActive.HasValue ? a.AssocActive.Value : false
                                                      }).AsQueryable<scAssociateData>();

              if (source.Count<scAssociateData>() == 1)
                scAssociateData = source.First<scAssociateData>();
              se0085CtEntities1.Database.Connection.Close();
            }
          }
          return scAssociateData;
        }

        public List<scOrderLineComment> rtnOrderLineComments(int OrderLineId)
        {
          // ISSUE: object of a compiler-generated type is created
          // ISSUE: variable of a compiler-generated type
          //clsEngineCTdB._Closure\u0024__10 closure10 = new clsEngineCTdB._Closure\u0024__10();
          // ISSUE: reference to a compiler-generated field
          //closure10.\u0024VB\u0024Local_OrderLineId = OrderLineId;
          List<scOrderLineComment> orderLineCommentList = new List<scOrderLineComment>();
          // ISSUE: reference to a compiler-generated field
          if (OrderLineId > 0)
          {
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
              //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
              //ParameterExpression parameterExpression1;
              //ParameterExpression parameterExpression2;
              //IQueryable<scOrderLineComment> source = (IQueryable<scOrderLineComment>) Queryable.Select<OrderLineComment, scOrderLineComment>((IQueryable<M0>) Queryable.OrderByDescending<OrderLineComment, DateTime?>(Queryable.Where<OrderLineComment>((IQueryable<M0>) se0085CtEntities1.OrderLineComments, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrderLineComment, bool>>((Expression) Expression.Equal(lc.OrderLine.OrderLineId, closure10.\u0024VB\u0024Local_OrderLineId, true, (MethodInfo) null), new ParameterExpression[1]
              //{
              //  parameterExpression1
              //})), (Expression<Func<M0, M1>>) (lc => lc.OrderLineCmtUpdDt)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<OrderLineComment, scOrderLineComment>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineCmtId)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineCmtId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineComment)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineCmt)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineCmtUpdDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineCmtUpdDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineCmtFwUpFlag)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineCmtFwUpFlag))), typeof (bool))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineCmtFwUpDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineCmtFwUpDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineCmtFwUpTypeId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderFollowUpType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderFollowUpType.get_OrderFwUpId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineCmtFwUpAssocId)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineCmtFwUpAssocId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineComment.set_OrderLineUpdAssocId)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineComment.get_OrderLineUpdAssocId))))), new ParameterExpression[1]
              //{
              //  parameterExpression2
              //}));
                IQueryable<scOrderLineComment> source = (from lc in se0085CtEntities1.OrderLineComments
                                                         where lc.OrderLine.OrderLineId == OrderLineId
                                                         orderby lc.OrderLineCmtUpdDt descending
                                                         select new scOrderLineComment { 
                                                             OrderLineCmtId = lc.OrderLineCmtId,
                                                             OrderLineId = lc.OrderLine.OrderLineId,
                                                             OrderLineComment = lc.OrderLineCmt,
                                                             OrderLineCmtUpdDt = lc.OrderLineCmtUpdDt.HasValue ? lc.OrderLineCmtUpdDt.Value : Conversions.ToDate("01/01/1901"),
                                                             OrderLineCmtFwUpFlag = lc.OrderLineCmtFwUpFlag.HasValue ? lc.OrderLineCmtFwUpFlag.Value : false,
                                                             OrderLineCmtFwUpDt = lc.OrderLineCmtFwUpDt.HasValue ? lc.OrderLineCmtFwUpDt.Value : Conversions.ToDate("01/01/1901"),
                                                             OrderLineCmtFwUpTypeId = lc.OrderFollowUpType.OrderFwUpId,
                                                             OrderLineCmtFwUpAssocId = lc.OrderLineCmtFwUpAssocId,
                                                             OrderLineUpdAssocId = lc.OrderLineUpdAssocId
                                                         }).AsQueryable<scOrderLineComment>();
              if (source != null && source.Count<scOrderLineComment>() > 0)
                orderLineCommentList = source.ToList<scOrderLineComment>();
              se0085CtEntities1.Database.Connection.Close();
            }
          }
          return orderLineCommentList;
        }

        public List<scOrderLineStat> rtnOrderLineStatus(int OrderLineId, int OrdSectsId = 0)
        {
          // ISSUE: object of a compiler-generated type is created
          // ISSUE: variable of a compiler-generated type
          //clsEngineCTdB._Closure\u0024__12 closure12 = new clsEngineCTdB._Closure\u0024__12();
          // ISSUE: reference to a compiler-generated field
         // closure12.\u0024VB\u0024Local_OrderLineId = OrderLineId;
          // ISSUE: reference to a compiler-generated field
          //closure12.\u0024VB\u0024Local_OrdSectsId = OrdSectsId;
          List<scOrderLineStat> scOrderLineStatList = new List<scOrderLineStat>();
          // ISSUE: reference to a compiler-generated field
          if (OrderLineId > 0)
          {
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
              //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
              //ParameterExpression parameterExpression1;
              //ParameterExpression parameterExpression2;
              //IQueryable<scOrderLineStat> source = (IQueryable<scOrderLineStat>) Queryable.Select<OrderLineStat, scOrderLineStat>((IQueryable<M0>) Queryable.OrderByDescending<OrderLineStat, DateTime?>(Queryable.Where<OrderLineStat>((IQueryable<M0>) se0085CtEntities1.OrderLineStats, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrderLineStat, bool>>((Expression) Expression.And((Expression) Expression.Equal(lc.OrderLine.OrderLineId, closure12.\u0024VB\u0024Local_OrderLineId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrdSectsId))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure12, typeof (clsEngineCTdB._Closure\u0024__12)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__12.\u0024VB\u0024Local_OrdSectsId))), true, (MethodInfo) null)), new ParameterExpression[1]
              //{
              //  parameterExpression1
              //})), (Expression<Func<M0, M1>>) (lc => lc.OrderLineStatUpdDt)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<OrderLineStat, scOrderLineStat>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatId)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderLineStatId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrdSectsId)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrdSectsId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatus)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderLineStatus)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatUpdDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderLineStatUpdDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatFwUpFlag)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderLineStatFwUpFlag))), typeof (bool))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatFwUpDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderLineStatFwUpDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatFwUpTypeId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_OrderFollowUpType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderFollowUpType.get_OrderFwUpId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineStatFwUpAssocId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_Associate))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLineStat.set_OrderLineUpdAssocId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLineStat.get_Associate1))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Associate.get_AssocId))))), new ParameterExpression[1]
              //{
              //  parameterExpression2
              //}));
                IQueryable<scOrderLineStat> source = (from lc in se0085CtEntities1.OrderLineStats
                                                      where lc.OrderLine.OrderLineId == OrderLineId
                                                      && lc.OrdSectsId == OrdSectsId
                                                      orderby lc.OrderLineStatUpdDt descending
                                                      select new scOrderLineStat
                                                      {
                                                          OrderLineStatId = lc.OrderLineStatId,
                                                          OrderLineId = lc.OrderLine.OrderLineId,
                                                          OrdSectsId = lc.OrdSectsId,
                                                          OrderLineStatus = lc.OrderLineStatus,
                                                          OrderLineStatUpdDt = lc.OrderLineStatUpdDt.HasValue ? lc.OrderLineStatUpdDt .Value : Conversions.ToDate("01/01/1901"),
                                                          OrderLineStatFwUpFlag = lc.OrderLineStatFwUpFlag.HasValue ? lc.OrderLineStatFwUpFlag.Value : false,
                                                          OrderLineStatFwUpDt = lc.OrderLineStatFwUpDt.HasValue ? lc.OrderLineStatFwUpDt.Value : Conversions.ToDate("01/01/1901"),
                                                          OrderLineStatFwUpTypeId = lc.OrderFollowUpType.OrderFwUpId,
                                                          OrderLineStatFwUpAssocId = lc.Associate.AssocId,
                                                          OrderLineUpdAssocId = lc.Associate1.AssocId
                                                      }).AsQueryable<scOrderLineStat>();

              if (source != null && source.Count<scOrderLineStat>() > 0)
                scOrderLineStatList = source.ToList<scOrderLineStat>();
              se0085CtEntities1.Database.Connection.Close();
            }
          }
          return scOrderLineStatList;
        }

        public List<scOrderImportInfo> rtnEngrActRelease(string AssemblyLine, DateTime ReleaseDtStart, DateTime ReleaseDtEnd)
        {
          //clsEngineCTdB._Closure\u0024__52 closure52 = new clsEngineCTdB._Closure\u0024__52();
          // ISSUE: reference to a compiler-generated field
          //closure52.\u0024VB\u0024Local_ReleaseDtStart = ReleaseDtStart;
          // ISSUE: reference to a compiler-generated field
          //closure52.\u0024VB\u0024Local_ReleaseDtEnd = ReleaseDtEnd;
          // ISSUE: reference to a compiler-generated field
          //closure52.\u0024VB\u0024Local_AssemblyLine = AssemblyLine;
          List<scOrderImportInfo> scOrderImportInfoList = new List<scOrderImportInfo>();
          if (true)
          {
            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
              //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
              //ParameterExpression parameterExpression1;
              //ParameterExpression parameterExpression2;
              //IQueryable<scOrderImportInfo> source = (IQueryable<scOrderImportInfo>) Queryable.Select((IQueryable<M0>) Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.ThenBy(Queryable.OrderBy(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.SEOrders.Distinct<SEOrder>(), (IEnumerable<M1>) se0085CtEntities1.OrderLines.Distinct<OrderLine>(), (Expression<Func<M0, M2>>) (od => od.OrderId), (Expression<Func<M1, M2>>) (ol => ol.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>) ((od, ol) => new{ od = od, ol = ol })), (IEnumerable<M1>) se0085CtEntities1.AssemblyLines, (Expression<Func<M0, M2>>) (data => data.ol.AssemblyLine.AssemLineId), (Expression<Func<M1, M2>>) (al => al.AssemLineId), (Expression<Func<M0, M1, M3>>) ((data, al) => new
              //{
              //  \u0024VB\u0024It1 = data,
              //  al = al
              //})), (IEnumerable<M1>) se0085CtEntities1.SEPlants, (Expression<Func<M0, M2>>) (data => data.al.SEPlant.SEPlantId), (Expression<Func<M1, M2>>) (pl => pl.SEPlantId), (Expression<Func<M0, M1, M3>>) ((data, pl) => new
              //{
              //  \u0024VB\u0024It1 = data,
              //  pl = pl
              //})), (IEnumerable<M1>) se0085CtEntities1.OrderLinesExts, (Expression<Func<M0, M2>>) (data => data.\u0024VB\u0024It1.\u0024VB\u0024It1.ol.OrderLineId), (Expression<Func<M1, M2>>) (oe => oe.OrderLine.OrderLineId), (Expression<Func<M0, M1, M3>>) ((data, oe) => new
              //{
              //  od = data.\u0024VB\u0024It1.\u0024VB\u0024It1.od,
              //  ol = data.\u0024VB\u0024It1.\u0024VB\u0024It1.ol,
              //  al = data.\u0024VB\u0024It1.al,
              //  pl = data.pl,
              //  oe = oe
              //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>, bool>>((Expression) Expression.Coalesce((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(\u0024VB\u0024It.ol.OrderLineShipped, (bool?) false, true, (MethodInfo) null), (Expression) Expression.Convert((Expression) Expression.Equal((Expression) Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Microsoft.VisualBasic.CompilerServices.Operators.CompareString)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_al), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineAbbrv))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure52, typeof (clsEngineCTdB._Closure\u0024__52)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__52.\u0024VB\u0024Local_AssemblyLine))), (Expression) Expression.Constant((object) false, typeof (bool))), (Expression) Expression.Constant((object) 0, typeof (int))), typeof (bool?))), (Expression) Expression.GreaterThanOrEqual((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineActEngrRelDt))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure52, typeof (clsEngineCTdB._Closure\u0024__52)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__52.\u0024VB\u0024Local_ReleaseDtStart))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_GreaterThanOrEqual)))), (Expression) Expression.LessThanOrEqual((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineActEngrRelDt))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure52, typeof (clsEngineCTdB._Closure\u0024__52)), FieldInfo.GetFieldFromHandle(__fieldref (clsEngineCTdB._Closure\u0024__52.\u0024VB\u0024Local_ReleaseDtEnd))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThanOrEqual)))), (Expression) Expression.LessThan((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), (Expression) Expression.Convert((Expression) Expression.Convert((Expression) Expression.Constant((object) "12-31-2020", typeof (string)), typeof (DateTime), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Conversions.ToDate))), typeof (DateTime?)), true, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (DateTime.op_LessThan)))), (Expression) Expression.Constant((object) false, typeof (bool))), new ParameterExpression[1]
              //{
              //  parameterExpression1
              //})), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineTargetDt)), (Expression<Func<M0, M1>>) (data => data.oe.OrderLineOrgShipDt)), (Expression<Func<M0, M1>>) (data => data.od.OrderFO)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineNum)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineSL)), (Expression<Func<M0, M1>>) (data => data.ol.OrderLineSS)), (Expression<Func<M0, M1>>) Expression.Lambda<Func<VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>, scOrderImportInfo>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_SEPlantId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_pl), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEPlant.get_SEPlantId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_AssemblyLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_al), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssemblyLine.get_AssemLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_od), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderFO)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_od), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderFO)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderJobName)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_od), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEOrder.get_OrderJobName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineNum)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineNum)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineSL)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSL)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineSS)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSS)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineTargetDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineTargetDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderImportInfo.set_OrderLineShipDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineShipDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineExtId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineExtId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineSER)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_ol), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineSER)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineBook)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineBook))), typeof (Decimal))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineNet)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineNet))), typeof (Decimal))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgTargetDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgTargetDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgShipDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgShipDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgAssyStDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgAssyStDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineCurAssyStDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineCurAssyStDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineActAssyStDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineActAssyStDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineOrgEngrRelDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineOrgEngrRelDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineCurEngrRelDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineCurEngrRelDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineActEngrRelDt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineActEngrRelDt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineNB4Dt)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineNB4Dt))), typeof (DateTime))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineEngrGrp)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineEngrGrp)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineMechClpx)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineMechClpx)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineElecClpx)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineElecClpx)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLineEngComposite)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLineEngComposite))), typeof (long))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scOrderLinesExt.set_OrderLinePeltCode)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>.get_oe), __typeref (VB\u0024AnonymousType_4<SEOrder, OrderLine, AssemblyLine, SEPlant, OrderLinesExt>))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLinesExt.get_OrderLinePeltCode))))), new ParameterExpression[1]
              //{
              //  parameterExpression2
              //}));
                IQueryable<scOrderImportInfo> source = (from od in se0085CtEntities1.SEOrders.Distinct()
                                                        join ol in se0085CtEntities1.OrderLines.Distinct()
                                                        on od.OrderId equals ol.SEOrder.OrderId
                                                        join al in se0085CtEntities1.AssemblyLines
                                                        on ol.AssemblyLine.AssemLineId equals al.AssemLineId
                                                        join pl in se0085CtEntities1.SEPlants
                                                        on al.SEPlant.SEPlantId equals pl.SEPlantId
                                                        join oe in se0085CtEntities1.OrderLinesExts
                                                        on ol.OrderLineId equals oe.OrderLine.OrderLineId
                                                        where al.AssemLineAbbrv == AssemblyLine
                                                        && oe.OrderLineOrgEngrRelDt >= ReleaseDtStart
                                                        && oe.OrderLineOrgEngrRelDt <= ReleaseDtEnd
                                                        orderby ol.OrderLineTargetDt,oe.OrderLineOrgShipDt,od.OrderFO,ol.OrderLineNum,ol.OrderLineSL,ol.OrderLineSS
                                                        select new scOrderImportInfo
                                                        {
                                                            OrderLineTargetDt = ol.OrderLineTargetDt.HasValue ? ol.OrderLineTargetDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineOrgShipDt = oe.OrderLineOrgShipDt.HasValue ? oe.OrderLineOrgShipDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderFO = od.OrderFO,
                                                            OrderLineNum = ol.OrderLineNum,
                                                            OrderLineSL = ol.OrderLineSL,
                                                            OrderLineSS = ol.OrderLineSS,
                                                            SEPlantId = pl.SEPlantId,
                                                            AssemblyLineId = al.AssemLineId,
                                                            OrderId = od.OrderId,
                                                            OrderJobName = od.OrderJobName,
                                                            OrderLineId = ol.OrderLineId,
                                                            OrderLineShipDt = ol.OrderLineShipDt.HasValue ? ol.OrderLineShipDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineExtId = oe.OrderLineExtId,
                                                            OrderLineSER = ol.OrderLineSER,
                                                            OrderLineBook = oe.OrderLineBook.HasValue ? oe.OrderLineBook.Value : new Decimal(),
                                                            OrderLineNet = oe.OrderLineNet.HasValue ? oe.OrderLineNet.Value : new Decimal(),
                                                            OrderLineOrgTargetDt = oe.OrderLineOrgTargetDt.HasValue ? oe.OrderLineOrgTargetDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineOrgAssyStDt = oe.OrderLineOrgAssyStDt.HasValue ? oe.OrderLineOrgAssyStDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineCurAssyStDt = oe.OrderLineCurAssyStDt.HasValue ? oe.OrderLineCurAssyStDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineActAssyStDt = oe.OrderLineActAssyStDt.HasValue ? oe.OrderLineActAssyStDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineOrgEngrRelDt = oe.OrderLineOrgEngrRelDt.HasValue ? oe.OrderLineOrgEngrRelDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineCurEngrRelDt = oe.OrderLineCurEngrRelDt.HasValue ? oe.OrderLineCurEngrRelDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineActEngrRelDt = oe.OrderLineActEngrRelDt.HasValue ? oe.OrderLineActEngrRelDt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineNB4Dt = oe.OrderLineNB4Dt.HasValue ? oe.OrderLineNB4Dt.Value : Conversions.ToDate("01/01/1901"),
                                                            OrderLineEngrGrp = oe.OrderLineEngrGrp,
                                                            OrderLineMechClpx = oe.OrderLineMechClpx,
                                                            OrderLineElecClpx = oe.OrderLineElecClpx,
                                                            OrderLineEngComposite = oe.OrderLineEngComposite.HasValue ? oe.OrderLineEngComposite.Value : 0,
                                                            OrderLinePeltCode = oe.OrderLinePeltCode
                                                        }).AsQueryable<scOrderImportInfo>();
              if (source != null && source.Count<scOrderImportInfo>() > 0)
              {
                scOrderImportInfoList = source.ToList<scOrderImportInfo>();
                clsPlant clsPlant = new clsPlant();
                scPlants scPlants = new scPlants();
                scPlants Plant = clsPlant.rtnPlantById(scOrderImportInfoList[0].SEPlantId);
                clsAssemblyLine clsAssemblyLine = new clsAssemblyLine(Plant);
                List<scOrderImportInfo>.Enumerator enumerator;
                enumerator = scOrderImportInfoList.GetEnumerator();
                try
                {
                  while (enumerator.MoveNext())
                  {
                    scOrderImportInfo current = enumerator.Current;
                    current.SEPlant = Plant;
                    current.AssemblyLine = (scLevels) clsAssemblyLine.rtnAssemblyLineById(current.AssemblyLineId);
                    current.OrderLineOE = this.rtnOrderLineAssocAssign(current.OrderLineId, emOLAssignType.OrderEngr);
                    current.OrderLineME = this.rtnOrderLineAssocAssign(current.OrderLineId, emOLAssignType.MechEngr);
                    current.OrderComments = this.rtnOrderLineComments(current.OrderLineId);
                    current.OrderStatus = this.rtnOrderLineStatus(current.OrderLineId, 0);
                  }
                }
                finally
                {
                  enumerator.Dispose();
                }
              }
              se0085CtEntities1.Database.Connection.Close();
            }
          }
          return scOrderImportInfoList;
        }

        public enum emOLAssignType
        {
            OrderEngr,
            MechEngr,
        }
    }
}
