Tag: c#
-
why use template in year_month class?
17 In MSVC chrono implementation I see the following code _EXPORT_STD template <int = 0> _NODISCARD constexpr year_month operator+(const year_month& _Left, const months& _Right) noexcept { const auto _Mo = static_cast<long long>(static_cast<unsigned int>(_Left.month())) + (_Right.count() – 1); const auto _Div = (_Mo >= 0 ? _Mo : _Mo – 11) / 12; return year_month{_Left.year() +…
-
Why does C++ have no std::invocable_r concept?
11 C++20 added concepts, and the standard library includes quite a few of them. One concept in particular caught my eye: std::invocable which validates that a functor can be invoked with a set of arguments. std::invocable is just syntactic sugar for std::is_invocable. However, the standard library further defines std::is_invocable_r which tests whether a functor can…
-
Is there a possibility when calling .ToUpper() that the new string requires more memory?
9 I want to use the the following function in the MemoryExtensions namespace public static int ToUpper(this ReadOnlySpan<char> source, Span<char> destination, CultureInfo? culture) My question now is: am I always safe when destination Span has the length of the source span? e.g. destination = stackalloc char[source.Length]; If no, can someone provide an example which string…
-
HotChocolate v13 GraphQL: how to get rid of “Input” suffix?
0 I’m building GraphQL API with C# and HotChocolate. The library adds "Input" suffix to type names which used as input arguments. I want to get rid of this behavior. And no, we’re not going to discuss why do I want this, and why it is a good practice (even if you really want to,…
-
.Net Core and GraphQL running query
0 This graphQL query runs in Postman, but is not returning data in my program. Any ideas? public static async Task RunAsync() { // Update port # in the following line. client.BaseAddress = new Uri(ServerUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // GET: Get data from Server var productRequest = new GraphQLRequest { Query = @"{ products…
-
Why is optimization forbidden if a C compiler cannot prove lack of UB?
10 If a C program has undefined behavior, anything can happen. Therefore compilers may assume that any given program does not contain UB. So, suppose our program contains the following: x += 5; /* Do something else without x in the meantime. */ x += 7; Of course, this can be optimized to /* Do…
-
Error in .net core with postgreSQL and graphQL to get json column for all records
0 I am using .NET Core 7.0 with PostgreSQL and graphQL. I am getting an error when I try to get all records from the database using the below code. When I try to get a single record then it is working fine. Error: The source ‘IQueryable’ doesn’t implement ‘IAsyncEnumerable<Vcp.Doctors.Gql.Models.ProviderInformation>’. Only sources that implement ‘IAsyncEnumerable’…
-
Why is changing a property from “init” to “set” a binary breaking change
8 I am coming back to C# after a long time and was trying to catch up using the book C# 10 in a Nutshell. The author there mentions that changing a property’s accessor from init to set or viceversa is a breaking change. I can understand how changing it from set to init can…
-
Hotchocolate Filter by BsonExtraElements
0 We have next entity: public class Product { public Guid Id { get; set; } public string Name { get; set; } = string.Empty; [BsonExtraElements] public Dictionary<string, object?> AdditionalData { get; set; } = new(); } This entity can have many dynamic data that can be stored inside AdditionalData property. Using attribute BsonExtraElements we…
-
How to upload file using graphql-client?
0 How can I make a mutation call from a client and upload a file? I can do it in the editor (screen) But I cannot figure out how to make the same from a client var request = new GraphQLRequest { Query = query, Variables = new { id = "id" }, }; var…