Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
convertir a decimal en consulta linq
var data = await dbContext.Set<OwnerData>().FromSqlRaw(@" SELECT [OWP].[OwnerProfileId], SELECT [OWP].[Email], FROM [user].[OwnerProfile] AS [OWP] CAST(ISNULL([OWB].[CustomBalance], 0) AS decimal(18, 3)) AS [CustomBalance] INNER JOIN [user].[OwnerBalance] AS [OWB] ON [OWB].[OwnerProfileId] = [OWP].[OwnerProfileId] WHERE [ThirdPartyRefId] = {0}", ownerProfileId) .ToListAsync();

Reescribo esto en una expresión linq como esta

 var data = await _context.Set<OwnerProfile>() .Include(x => x.OwnerBalances) .Where(x => x.ThirdPartyRefId== ownerProfileId) .ToListAsync();

no estoy seguro de cómo configurar esto

 CAST(ISNULL([OWB].[CustomBalance], 0) AS decimal(18, 3)) AS [CustomBalance]

en consulta lambda

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Sin tener definiciones de clase, es un poco difícil darle detalles, pero podría intentar agregar algo como:

 var data = await _context.Set<OwnerProfile>() .Include(x => x.OwnerBalances) .Where(x => x.ThirdPartyRefId== ownerProfileId) .Select(x => new { x.Prop1, x.Prop2, CustomerBalance = x.CustomerBalance.Value != null ? x.CustomerBalance.Value : 0 }) .ToListAsync();

También puede mover la declaración de selección fuera de la consulta:

 var newData = data.Select(x => new { x.Prop1, x.Prop2, CustomerBalance = x.CustomerBalance.Value != null ? x.CustomerBalance.Value : 0 })

Es posible que pueda usar el acceso condicional en la segunda versión, pero posiblemente no en la primera.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!