将字符串值传递给数据访问层

时间:2013-01-24 00:44:31

标签: c# linq entity-framework-4 linq-to-xml

我只是坚持将我的字符串变量传递给我的数据访问层。

这是我的主控台

 class Program
{
    static void Main(string[] args)
    {  
            String BookingTime="1000345";
            var BookingStart = new SchedSAPEntities.ResourceBookingEntity.ResourceBooking(string Bookingtime);
   }

}

SchedSAPEntities.ResourceBookingEntity.ResourceBooking(string Bookingtime); //我试图将字符串变量(1000345)传递给ResourceBooking方法。

这是我的数据访问层

 public class ResourceBookingEntity
{
    public class ResourceBooking
    {
        private String _PRJ_ID;

        public ResourceBooking(String APRJ_ID )
        {
            _PRJ_ID = APRJ_ID;

        }
        public String PRJ_ID { get { return _PRJ_ID; } }
        }
}


  public class ResourceBookingList : List<SchedSAPEntities.ResourceBookingEntity.ResourceBooking>
    {
        public ResourceBookingList(SchedwinEntities db)
        {
                var query =
                (from PROJECTS in db.PROJECTS
                 join WOes in db.WOes on PROJECTS.PRJ_ID equals WOes.PRJ_ID
                 join SEVT_EX in db.SEVT_EX on SEVTs.SESID equals SEVT_EX.SESID into SEVT_EX_join
                 from SEVT_EX in SEVT_EX_join.DefaultIfEmpty()
                 where
                   (new string[] { "1", "2" }).Contains((PROJECTS.STAT.TrimEnd()).TrimStart()) &&
                   (WOes.STAT.TrimEnd()).TrimStart() == "6" &&
                   ((SEVTs.RESTYPE == 5 ||
                   SEVTs.RESTYPE == 0) &&
                   **SEVTs.T_START.TrimStart() == BookingStart**//Am trying to pass the value here
                 orderby
                   PROJECTS.PRJ_ID,
                   WOes.WONUM
                 select new
                 {
                     PROJECTS.PRJ_ID,

                 }).Take(10);
            foreach (var r in query)
                Add(new SchedSAPEntities.ResourceBookingEntity.ResourceBooking(
                    r.PRJ_ID, r.USER3, r.USER9, r.WONUM));
                    var ResourceBooking = query.ToList();
        }
    }

1 个答案:

答案 0 :(得分:0)

不需要将类型传递给方法,并记住C#区分大小写。

static void Main(string[] args)
    {  
            String BookingTime="1000345";
            var BookingStart = new SchedSAPEntities.ResourceBookingEntity.ResourceBooking(BookingTime);
   }