Does .First() operate at linq level or on the returned enumerable collection?
I came across a colleagues code and thought it was possibly inefficient 

    bool any = (from c in listDeviceMaxDate
                 where c.DeviceKey == m_deviceList[i].deviceKey
                 select c).Any();

    if (!any)
    {
        latestDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
    }
    else
    {
        // from the list we have get the lastest max date from the flow table
        DeviceDateTimeItem temp = (from c in listDeviceMaxDate
                                    where c.DeviceKey == m_deviceList[i].deviceKey
                                    select c).First();

        latestDate = Convert.ToDateTime(temp.dateTimeMax);
    }

My first instinct is to store the linq query and then just reference it as needed but then I realised that the `First()` operator may prevent linq from actually getting ALL the rows which an unconstrained query would do.

How I initially thought about restructuring the code:

    var deviceList = from c in listDeviceMaxDate
                                where c.DeviceKey == m_deviceList[i].deviceKey
                                select c;

    if (!deviceList.Any())
    {
        latestDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
    }
    else
    {
        // from the list we have get the lastest max date from the flow table
        DeviceDateTimeItem temp = deviceList.First();

        latestDate = Convert.ToDateTime(temp.dateTimeMax);
    }

My question is does the `First()` call on the second linq query prevent it from returning all results, and as such, is it actually quicker to do it the original way?
Does .First() operate at linq level or on the returned enumerable collection?
===

I came across a colleagues code and thought it was possibly inefficient 

    bool any = (from c in listDeviceMaxDate
                 where c.DeviceKey == m_deviceList[i].deviceKey
                 select c).Any();

    if (!any)
    {
        latestDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
    }
    else
    {
        // from the list we have get the lastest max date from the flow table
        DeviceDateTimeItem temp = (from c in listDeviceMaxDate
                                    where c.DeviceKey == m_deviceList[i].deviceKey
                                    select c).First();

        latestDate = Convert.ToDateTime(temp.dateTimeMax);
    }

My first instinct is to store the linq query and then just reference it as needed but then I realised that the `First()` operator may prevent linq from actually getting ALL the rows which an unconstrained query would do.

How I initially thought about restructuring the code:

    var deviceList = from c in listDeviceMaxDate
                                where c.DeviceKey == m_deviceList[i].deviceKey
                                select c;

    if (!deviceList.Any())
    {
        latestDate = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue;
    }
    else
    {
        // from the list we have get the lastest max date from the flow table
        DeviceDateTimeItem temp = deviceList.First();

        latestDate = Convert.ToDateTime(temp.dateTimeMax);
    }

My question is does the `First()` call on the second linq query prevent it from returning all results, and as such, is it actually quicker to do it the original way?