Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Select() quesiton?

$
0
0

Hi there,

I have an asp.net web API solution. I am querying a table in my database. I am using EF6. I implemented generic repository and I wonder if I can convert my query into something like this in order to use it in the generic repo.

Here is my query:

            var gameBankResultVM = await (context.GameBanks
                .Where(l => l.referenceId == confirm.referenceId)
                .Select(g => new GameBankConfirmResponseVM()
                {
                    referenceId = g.referenceId,
                    paymentId = null,
                    productCode = g.productCode,
                    quantity = g.quantity,
                    deliveredQuantity = g.quantity,
                    currency = g.currency,
                    version = g.version,
                    signature = g.signature,
                    ApplicationCode = g.ApplicationCode,
                    productDescription = g.productDescription,
                    unitPrice = g.unitPrice,
                    totalPrice = g.totalPrice,
                    totalPayablePrice = g.totalPrice,
                    coupons = g.coupons.Select(c => new GameCouponBankVM()
                    {
                        Pin = c.Pin,
                        Serial = c.Serial,
                        expiryDate = c.expiryDate
                    }).ToList()
                })).ToListAsync();

Here is a generic repo sample which I would like to convert my query:

 public virtual async Task<List<TEntity>> GetGamesProjectionAsync(
            Expression<Func<TEntity, bool>> where)
        {

            return await dbSet.Where(where).ToListAsync();
        }

I couldn't find a way to implement select portion of my query. Is there any way that I can do it?

Best Regards.


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>