Well, thanks to the suggestion of @Sebin to use Nhibernate Linq I've found that this is working in both my test case and hopefully in many others
List<DateTime> tmpList = session.Query<Ricevuta>()
.Select( x => x.DataRicezioneFile )
.Distinct()
.ToList();
list = tmpList.OrderByDescending(x=>x.Year)
.Select(x=>x.Year)
.Distinct()
.ToList<int>();
For a complete answer, is it possible to do the same with a full linq query as this:
var query = from ric in session.Query<Ricevuta>()
select ric.DataRicezioneFile;
List<DateTime> tmpList= query.ToList();
list = tmplist.OrderByDescending( x => x.Year ).Select( x => x.Year ).Distinct().ToList<int>();
In both case is necessary to use a tmpList of DateTime because using a direct DateTime.Year request is not working the same on different DBM.