using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FAS_LIB
{
    public class clsAssemblyLine
    {
        private scPlants _Plant;
        private scAssemblyLine _AssemblyLine;
        private List<scAssemblyLine> _AssemblyLinesList;

        public scPlants Plant
        {
            get
            {
                return this._Plant;
            }
            set
            {
                this._Plant = value;
            }
        }

        public scAssemblyLine AssemblyLine
        {
            get
            {
                return this._AssemblyLine;
            }
            set
            {
                this._AssemblyLine = value;
            }
        }
        public clsAssemblyLine(scPlants Plant)
        {
            this._Plant = new scPlants();
            this._AssemblyLinesList = new List<scAssemblyLine>();
            this._Plant = Plant;
            this._AssemblyLine = new scAssemblyLine();
            //this.GetdBConnString();
        }

        public clsAssemblyLine(scLevels Plant)
        {
            this._Plant = new scPlants();
            this._AssemblyLinesList = new List<scAssemblyLine>();
            this._Plant.PlantLevel = Plant;
            this._AssemblyLine = new scAssemblyLine();
            //this.GetdBConnString();
        }

        public List<scAssemblyLine> rtnAssemblyLines(bool ActiveOnly)
        {
      
          List<scAssemblyLine> scAssemblyLineList = new List<scAssemblyLine>();
          using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
          {
            //se0085CtEntities1.Database.Connection.ConnectionString = this._CTConnection;
            //ParameterExpression parameterExpression1;
            //ParameterExpression parameterExpression2;
        
            //IQueryable<scAssemblyLine> source = (IQueryable<scAssemblyLine>) Queryable.Select<SE0085.dBc.AssemblyLine, scAssemblyLine>(Queryable.Where<SE0085.dBc.AssemblyLine>((IQueryable<M0>) se0085CtEntities1.AssemblyLines, (Expression<Func<M0, bool>>) Expression.Lambda<Func<SE0085.dBc.AssemblyLine, bool>>((Expression) Expression.Coalesce((Expression) Expression.And((Expression) Expression.Convert((Expression) Expression.Equal(al.SEPlant.SEPlantId, this._Plant.PlantId, true, (MethodInfo) null), typeof (bool?)), (Expression) Expression.Or((Expression) Expression.Equal((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineActive))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure57, typeof (clsAssemblyLine._Closure\u0024__57)), FieldInfo.GetFieldFromHandle(__fieldref (clsAssemblyLine._Closure\u0024__57.\u0024VB\u0024Local_ldActive1))), typeof (bool?)), true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) parameterExpression1, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineActive))), (Expression) Expression.Convert((Expression) Expression.Field((Expression) Expression.Constant((object) closure57, typeof (clsAssemblyLine._Closure\u0024__57)), FieldInfo.GetFieldFromHandle(__fieldref (clsAssemblyLine._Closure\u0024__57.\u0024VB\u0024Local_ldActive2))), typeof (bool?)), true, (MethodInfo) null))), (Expression) Expression.Constant((object) false, typeof (bool))), new ParameterExpression[1]
            //{
            //  parameterExpression1
            //})), (Expression<Func<M0, M1>>) Expression.Lambda<Func<SE0085.dBc.AssemblyLine, scAssemblyLine>>((Expression) Expression.MemberInit(Expression.New((ConstructorInfo) MethodBase.GetMethodFromHandle(__methodref (scAssemblyLine.\u002Ector)), (Expression[]) null), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scLevels.set_LevelId)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineId)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scLevels.set_LevelAbbrv)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineAbbrv)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scLevels.set_LevelName)), (Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineName)))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scLevels.set_LevelValue)), (Expression) Expression.ConvertChecked((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineValue))), typeof (byte))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scLevels.set_LevelActiveBool)), (Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_AssemLineActive))), typeof (bool))), (MemberBinding) Expression.Bind((MethodInfo) MethodBase.GetMethodFromHandle(__methodref (scLevels.set_LevelParentId)), (Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SE0085.dBc.AssemblyLine.get_SEPlant))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (SEPlant.get_SEPlantId))))), new ParameterExpression[1]
            //{
            //  parameterExpression2
            //}));

              IQueryable<scAssemblyLine> source = (from s in se0085CtEntities1.AssemblyLines
                                                  // where (s.AssemLineActive = ActiveOnly)
                                                   select new scAssemblyLine
                                             {
                                                 LevelParentId = s.SEPlantId,
                                                 LevelName = s.AssemLineName,
                                                 LevelAbbrv = s.AssemLineAbbrv
                                             }).AsQueryable<scAssemblyLine>();

            if (source != null && source.Count<scAssemblyLine>() > 0)
              scAssemblyLineList = source.ToList<scAssemblyLine>();
            this._AssemblyLinesList = scAssemblyLineList;
            se0085CtEntities1.Database.Connection.Close();
          }
          return scAssemblyLineList;
        }
    }
}
