/// <summary> /// Creates and returns a new object for the GET_EVENTS_COMPONENT table. /// </summary> /// <param name="getComponentAuto"></param> /// <param name="ltd"></param> /// <param name="eventsAuto"></param> /// <param name="recordStatus"></param> /// <returns></returns> public GET_EVENTS_COMPONENT createComponentEvent(int getComponentAuto, int ltd, long eventsAuto, int recordStatus) { GET_EVENTS_COMPONENT componentEvent = new GET_EVENTS_COMPONENT(); componentEvent.get_component_auto = getComponentAuto; componentEvent.ltd = ltd; componentEvent.events_auto = eventsAuto; componentEvent.recordStatus = recordStatus; return(componentEvent); }
/// <summary> /// Find and return the previous component event given the GET Component auto /// and an event date. /// </summary> /// <param name="_gContext"></param> /// <param name="GETComponentAuto"></param> /// <param name="eventDate"></param> /// <returns></returns> public GET_EVENTS_COMPONENT findPreviousComponentEvent(GETContext _gContext, long GETComponentAuto, DateTime eventDate) { GET_EVENTS_COMPONENT result = new GET_EVENTS_COMPONENT(); DateTime eventDate2 = new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, 23, 59, 59); result = (from c in _gContext.GET_EVENTS_COMPONENT join ge in _gContext.GET_EVENTS on c.events_auto equals ge.events_auto where c.get_component_auto == GETComponentAuto && ge.event_date <= eventDate2 && ge.recordStatus == 0 orderby ge.event_date descending, ge.events_auto descending select c).FirstOrDefault(); return(result); }