Show / Hide Table of Contents

    IDataStore<TModel>.Max(Func<TModel, long> selector) Method

    .NET Standard 2.x

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

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    long Max(Func<TModel, long> selector);
    

    Parameters

    selector Func<TModel, long>

    A transform function to apply to each row.

    Returns

    System.Long

    The maximum value.

    Examples

    The following code example demonstrates how to get the maximum value for budget from the Department table.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStore_GenericExamples
    {
        public class MaxExample
        {
            private readonly SchoolContext _context;
    
            public MaxExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore<D_Department>(_context);
    
                datastore.Retrieve();
    
                // Gets the maximum value for budget.
                // The largest budget is 350000.00
                long maxBudget = datastore.Max(d => (long)d.Budget);
    
                Console.WriteLine("Max Budget: {0}", maxBudget);
    
                /*This code produces the following output:
                 
                Max Budget: 350000.0000
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon