Tvde1
Tvde1
CC#
Created by Szylek on 4/11/2025 in #help
Linking incremental generator to the consumer project
I think the fortune tellers are on holiday at the moment, so in order to help you we would like to see the projects and build output ☺️
10 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
let me try using the Func<T, bool> instead of an expression - but I'm pretty certain EF will refuse to attempt to translate it
26 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
a predicate is a delegate that is equal to Func<T, bool>..?
26 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
I can use:
var outstandingBalance = 123;
context.Contracts
.WhereIsPaid(outstandingBalance)
.ToListAsync();

public static IQueryable<Contract> WhereIsPaid(this IQueryable<Contract> query, int amount)
{
return query.Where(contract => contract.PaymentAttempts.Any(y =>
(y as BankPaymentAttempt)!.AmountPaid >= amount ||
(y as VipUserPaymentAttempt)!.IsSuperVip)
);
}
var outstandingBalance = 123;
context.Contracts
.WhereIsPaid(outstandingBalance)
.ToListAsync();

public static IQueryable<Contract> WhereIsPaid(this IQueryable<Contract> query, int amount)
{
return query.Where(contract => contract.PaymentAttempts.Any(y =>
(y as BankPaymentAttempt)!.AmountPaid >= amount ||
(y as VipUserPaymentAttempt)!.IsSuperVip)
);
}
Though this defeats the open-closed principle. I would rather have each class implement their own filter expression
26 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
I wish to receive a query which looks like
SELECT * FROM [Contracts]
LEFT JOIN (
SELECT [pa].[Id], [pa].[ContractId], [e].Property, [e0].OtherProperty CASE
WHEN [e].[Id] IS NOT NULL THEN N'VipUserPaymentAttempt'
WHEN [e0].[Id] IS NOT NULL THEN N'BankPaymentAttempt'
END AS [Discriminator]
FROM [PaymentAttempt] AS [pa]
LEFT JOIN [BankPaymentAttempt] AS [e] ON [pa].[Id] = [e].[Id]
LEFT JOIN [VipUserPaymentAttempt] AS [e0] ON [pa].[Id] = [e0].[Id]
) AS [s] ON [c].[Id] = [s].[ContractId]
WHERE ([e] IS NULL OR [e].Amount > @__input_amount) -- or something
SELECT * FROM [Contracts]
LEFT JOIN (
SELECT [pa].[Id], [pa].[ContractId], [e].Property, [e0].OtherProperty CASE
WHEN [e].[Id] IS NOT NULL THEN N'VipUserPaymentAttempt'
WHEN [e0].[Id] IS NOT NULL THEN N'BankPaymentAttempt'
END AS [Discriminator]
FROM [PaymentAttempt] AS [pa]
LEFT JOIN [BankPaymentAttempt] AS [e] ON [pa].[Id] = [e].[Id]
LEFT JOIN [VipUserPaymentAttempt] AS [e0] ON [pa].[Id] = [e0].[Id]
) AS [s] ON [c].[Id] = [s].[ContractId]
WHERE ([e] IS NULL OR [e].Amount > @__input_amount) -- or something
26 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
I'm trying to refrain from making a complex expression tree soup - even though I know that is possible
26 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
EF.CompileQuery also wouldn't help me in this case I think
26 replies
CC#
Created by Tvde1 on 4/9/2025 in #help
abstract methods inside EF core queries
I'm thinking of
class BankPaymentAttempt : PaymentAttempt
{
public Expression<Func<int, bool>> HasPaid = (int amount) => AmountPaid >= amount;
}
class BankPaymentAttempt : PaymentAttempt
{
public Expression<Func<int, bool>> HasPaid = (int amount) => AmountPaid >= amount;
}
but how would I use this inside an any?
26 replies
CC#
Created by Faker on 2/19/2025 in #help
✅ is there a difference between NET core and .NET and .NET framework ?
.NET Framework was the first to exist. It is Windows only. In 2016, Microsoft decided to rewrite it and make it cross platform. That new codebase was called .NET Core As of 2021, .NET core is renamed to .NET> So: * .NET = Newest version (use this) * .NET Core = 2016-2021, deprecated * .NET Framework = Windows only, used for legacy systems
6 replies
CC#
Created by Faker on 2/19/2025 in #help
✅ is there a difference between NET core and .NET and .NET framework ?
It is not "important" per se to know how they differ. Just know that .NET is the current version, and .NET Core and .NET Framework are older and have their limitations, but might still be used by companies
6 replies
CC#
Created by felsokning on 1/30/2025 in #help
Populate `EnvelopeRecipientCollection` on `Recipients` Property of a `MailItem` in Transport Agent
I would build a layer between this external API and your business logic. That way you can test your business logic without needing to construct external models
14 replies
CC#
Created by felsokning on 1/30/2025 in #help
Populate `EnvelopeRecipientCollection` on `Recipients` Property of a `MailItem` in Transport Agent
Is there a reason you are trying to work with classes that are from an external library? I feel like you should not be unit testing those
14 replies
CC#
Created by Faker on 1/18/2025 in #help
✅ Taking user input using Console.ReadLine()
Some people have different tastes, but the majority of people use var whenever possible
44 replies
CC#
Created by Faker on 1/18/2025 in #help
✅ Taking user input using Console.ReadLine()
You have the option to write down the type, or to type var and let the compiler pick the type based on the what the function returns
44 replies
CC#
Created by Quantix on 1/11/2025 in #help
"Correct" way of setting up DB for Aspire.NET MicroServices following CA
Each microservice should be responsible for its own database, so there shouldn't be a microservice initializing the other databases
18 replies
CC#
Created by Jiry_XD on 11/18/2024 in #help
✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.
I don't remember. Something like "blazor empty page ASPNETCORE_ENVIRONMENT"
8 replies
CC#
Created by Jiry_XD on 11/18/2024 in #help
✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.
Yay!
8 replies
CC#
Created by Jiry_XD on 11/18/2024 in #help
✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.
8 replies
CC#
Created by nathanAjacobs on 10/6/2024 in #help
Is it necessary to setup validation constraints at the api level and database level?
Unique constraints on database level are still useful for concurrency issues or if a bug in the business logic exists
6 replies