Northwind.Data.NorthwindEntities.usp_GetTotalIncomesBySupplierNameAndPeriod C# (CSharp) Method

usp_GetTotalIncomesBySupplierNameAndPeriod() public method

public usp_GetTotalIncomesBySupplierNameAndPeriod ( string supplierName, Nullable startDate, Nullable endDate ) : ObjectResult>
supplierName string
startDate Nullable
endDate Nullable
return ObjectResult>
        public virtual ObjectResult<Nullable<decimal>> usp_GetTotalIncomesBySupplierNameAndPeriod(string supplierName, Nullable<System.DateTime> startDate, Nullable<System.DateTime> endDate)
        {
            var supplierNameParameter = supplierName != null ?
                new ObjectParameter("supplierName", supplierName) :
                new ObjectParameter("supplierName", typeof(string));
    
            var startDateParameter = startDate.HasValue ?
                new ObjectParameter("startDate", startDate) :
                new ObjectParameter("startDate", typeof(System.DateTime));
    
            var endDateParameter = endDate.HasValue ?
                new ObjectParameter("endDate", endDate) :
                new ObjectParameter("endDate", typeof(System.DateTime));
    
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Nullable<decimal>>("usp_GetTotalIncomesBySupplierNameAndPeriod", supplierNameParameter, startDateParameter, endDateParameter);
        }
    }

Usage Example

        static decimal? GetTotalIncomes(string supplierName, DateTime? startDate, DateTime? endDate)
        {
            using (NorthwindEntities northwindEntites = new NorthwindEntities())
            {
                var totalIncomesSet = northwindEntites
                    .usp_GetTotalIncomesBySupplierNameAndPeriod(supplierName, startDate, endDate);

                foreach (var totalIncomes in totalIncomesSet)
                {
                    return totalIncomes;
                }
            }

            return null;
        }