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

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
        //}));
        //        if (source.Count<scItemMaster>() == 1)
        //            scItemMaster = source.First<scItemMaster>();
                se0085CtEntities1.Database.Connection.Close();
            }
            return scItemMaster;
        }
    }
}
