简体   繁体   中英

Error with Select statement in Lambda expression

I have the following code :

getAllResult.GroupBy(g => g.OriginatingTransactionID)
.Select(r => 
{
    usp_GetAll_Result getAllResult1 = r.Select(x => x).FirstOrDefault();
    Bundle bundle = new Bundle
    {
        BundleName = getAllResult1.BundleName,
        BundleStatusCode = getAllResult1.BundleStatusCode,
        BundleStatusReasonCode = getAllResult1.BundleStatusReasonCode
    };
}).ToList();

I am getting the error while compiling:

The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

.Select() returns a value. Currently you are not returning anything from your expression.

Just return your bundle.

Bundle bundle = new Bundle
                {
                    BundleName = getAllResult1.BundleName,
                    BundleStatusCode = getAllResult1.BundleStatusCode,
                    BundleStatusReasonCode = getAllResult1.BundleStatusReasonCode
                };

return bundle;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM