Show / Hide Table of Contents

    IDataStore<TModel>.Min(Func<TModel, float> selector, Predicate<TModel> predicate) Method

    .NET Standard 2.x

    Invokes a transform function on each row of the primary buffer in the DataStore and returns the minimum result value.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    float Min(Func<TModel, float> selector, Predicate<TModel> predicate);
    

    Parameters

    selector Func<TModel, float>

    A transform function to apply to each row.

    predicate System.Predicate<TModel>

    A function to evaluate each row in the primary buffer for a condition.

    Returns

    System.Float

    The minimum value.

    Examples

    The following code example demonstrates how to get the minimum value for budget from the Department table which meets the criteria Departmentid is larger than 3.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStore_GenericExamples
    {
        public class MinExample
        {
            private readonly SchoolContext _context;
    
            public MinExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example14()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore<D_Department>(_context);
    
                datastore.Retrieve();
    
                // Gets the minimum value for budget where departmentid > 3
                // The smallest budget that meets the criteria is 200000.00
                float MinBudget = datastore.Min(d => (float)d.Budget, d => d.Departmentid > 3);
    
                Console.WriteLine("Min Budget: {0}", MinBudget);
    
                /*This code produces the following output:
                 
                Min Budget: 200000.00
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon