C# - Dependency injection - Repository Layer - Calling select

I realized a need for dependency injection as I need a new class but couldn't create one as an entity because the class doesn't exist in the database. I successfully did the unity part right. I am just stuck with calling it. Following code is what I tried, but it doesn't let me use the select option. The error I get is

The type arguments for method cannot be inferred from the usage. Try specifying the type arguments explicitly

I googled that error but most of the people who posted that error have a long code history behind it which made it difficult for me to understand.

Can anyone see where am I going wrong??

   public virtual List<IMcrVolumeAdjustmentMainGrid> GetVolumeAdjustmentByLoadId(Guid? LoadId)
    {
        var AdjustmentGroups = UnitOfWork.Context.Set<McrVolumeAdjustment>()
                .Include(y => y.McrVolumeAdjustmentReason)
                .Where(x => x.McrPickup.McrLoadId == LoadId && x.McrVolumeAdjustmentReason.McrVolumeAdjReasonCode != McrVolumeAdjReasonCodeEnum.LoadRejected)
                .GroupBy(x => new { x.McrVolumeAdjustmentReason, x.EffectiveYear, x.EffectiveMonth, x.LastModifierIdentityName })
                .ToList();
        return AdjustmentGroups.Select(
               x =>
               {
                   var entry = DefaultContainer.Current.Resolve<IMcrVolumeAdjustmentMainGrid>();
                   entry.EffectiveDate = new DateTime(x.Key.EffectiveYear, x.Key.EffectiveMonth, 01);
                   entry.McrReason = x.Key.McrVolumeAdjustmentReason.Description;
                   entry.LastModifierIdentityName = x.Key.LastModifierIdentityName;
                   entry.TotalAdjustment = x.Sum(y => y.AdjustedMilkVolume);
               }
            ).ToList();
    }

Answers


It seems that your SELECT statement is invalid because you return nothing. You should add "return entry;" code to the end of the select lambda.


Need Your Help

How to upgrade filters to support Servlet 3.0 asynchronous servlet

java-ee-6 server-push servlet-3.0

I have a servlet which is used to fetch data from many third party REST datapoints, integrate all the data and report the data in a HTML format. I also have a filter which has the following flow -