Questions tagged [.net]

.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

Filter by
Sorted by
Tagged with
0
votes
0answers
20 views

Handling disconnected entity scenario in Entity Framework Core

As some you you may know, handling disconnected entities in EF can be a bit of a headache. After a really long weekend, I managed to make it work for my use case and refactor the code to the best of ...
2
votes
1answer
22 views

Send Data from DynamoDB to Lambda (C#) and to Azure Queue

I am a beginner and trying to send data from AWS DynamoDB to Azure Queues. Note that this code will be invoked 10,000 and alot more. Can you guys review it once. ...
1
vote
0answers
14 views

Calling GetRequestStream and GetResponseStream for the same http request

I have one method in C# where I am making service call by creating object of HttpWebRequest. With I object there are two methods being used ...
5
votes
4answers
202 views

All your Base - Exercism.io

This is an exercise on the website Exercism. I am self taught trying to learn C# and C++. This is the information from the readme. Convert a number, represented as a sequence of digits in one base,...
1
vote
0answers
31 views

Handle login method with external users and LDAP users

I'm working with a ASP.NET Core (v2.2) Web Api project and implemented some APIs. However, I'm facing performance issues, hence trying to optimizing the code. Here is the login API code. ...
2
votes
1answer
70 views

Programmatically getting the GUID of an application

Intrigued by the events chronicled here (also here and here), I saw the inherent utility in having a program-specific GUID available. The SO answers that were correct seemed a bit tightly-coupled and ...
1
vote
1answer
76 views

Getting names/values of multiple properties [closed]

Lets say I have one method, which extracts property name and value: ...
1
vote
0answers
49 views

Extension method: Task<T>.CoalesceAwait

There has been ongoing concern about the question of awaiting a task that could possibly be null, as when using null-coalescing operators. Consider the following: ...
1
vote
1answer
74 views

Serializing object graph to proprietary binary file

I'm creating a class library to read/write .3di files which are binary files describing 3D models for a video game. This review is for the write/serialization process. I've mapped the different ...
2
votes
1answer
105 views

Can this async method be improved or simplified

I was tasked to write process that initially seemed like a straight forward thing. "Fetch data from database, create a cache object, and assign this data to it. Use existing class to model this after."...
1
vote
0answers
170 views

Dependency Injected StackExchange.Redis Client

I am currently building cache for my application, and I would like to have my redis cache client work the same way you would dependency inject a DbContext. I am using StackExchange.Redis to manage my ...
2
votes
0answers
41 views

Generic CQRS Query handler with custom return type

I am trying to build a generic query handler using the MediatR (v8) library. Let's jump to the code: First of all I have an abstract query class like this: ...
1
vote
0answers
32 views

calculate time in data processing into XML and CSV [closed]

I made a program (C#, .NET) that calculates time for XML and CSV export and please I have a question for improving my knowledge in programming. Do you think that I can improve the structure of the ...
1
vote
0answers
53 views

Reactive Extensions wrapper around Confluent.Kafka for .NET

Just an Rx wrapper around Kafka to represent topic consumption as IObservable<T>: ...
1
vote
0answers
37 views

Accurately measure ASP.NET Core 3.x actions execution times (Web API project)?

I want to be able to log the time spent by a certain Web API action in an ASP.NET Core 3.x application. This is a very old question from ASP.NET which relies on global action filters, but in ASP.NET ...
3
votes
0answers
59 views

Creating SQL Server Database Users Dynamically from User Input

The Application I have an application in testing that runs off of an MS SQL Server database. The app allows users to authenticate using Windows authentication (that is, using the Windows username the ...
4
votes
2answers
61 views

Feedback on automatic form filling with reflection

Context: I need to fill a handful of .docx templates with answers that come from form.responses, which is a dynamic object that comes from a JSON and can have different properties that vary according ...
3
votes
1answer
120 views

Bulk inserting/updating people with additional properties

The below code is either inserting or updating a list of person with a lot of properties of these persons. The code is repeating itself a lot but is working as intended. Unfortunately making all the ...
4
votes
3answers
98 views

Method that fetches rows from database and maps it to a Model class with SqlDataReader

So, I have a project that has a lot of methods that look alike. In the below method as you can see it just fetches a bunch of rows from database and maps it to a model class. In this case ...
12
votes
0answers
132 views

Open source project to ease the Assert part from the functional tests of .Net Core Web APIs

I have built an open-source project based on FluentAssertions in order to solve some recurring tasks I was doing while testing the .Net Core APIs I'm developing. I find the capability of doing in ...
2
votes
1answer
1k views

Generate Unique ID in C#

Objective To create a unique id with few characters as possible. Language: C# Engine Unity3D Target : iOS && iPadOS Scenario I found quite a few solutions from Stack Exchange but would ...
1
vote
0answers
41 views

PowerShell script to execute Docker maintenance, optionally non-interactively

Problem Developers in my team are new to Docker. I wanted to provide a way to accomplish general Docker housekeeping tasks (like pruning unused images and compacting the Hyper-V volume) largely ...
0
votes
1answer
244 views

Cancel Long Running Query using Cancellation Token AND SqlCommand.Cancel()

I need to be able to cancel a long running query programmatically through our application. The code below will kick off a long running query and give control back to the main thread. At any ...
3
votes
2answers
106 views

Validate if either or both of two fields has been provided, as a ValidationAttribute

I have a binding model where at least one of two fields must be specified. I can't just set them both as [Required]. Here is what I came up with: ...
4
votes
1answer
78 views

WPF Custom Control with a Single ObservableCollection DependencyProperty

I'm learning how to write WPF custom controls. My example, NameLister, exposes a single DependencyProperty, Names, of type ...
3
votes
1answer
59 views

Formatting a type's name

I'm writing a code generation library, I've exposed a couple of methods and of course in order to define a member you need to specify it's type, the easiest way is to use ...
1
vote
0answers
68 views

Running some code every day at certain times

I am currently developing a windows service in C# which is supposed to run a data import every day at configurable times. For this purpose I have created a class "ExecutionTime" which contains the ...
5
votes
1answer
138 views

Encrypting credit card data

I need an encryption algorithm that would be secure enough to store credit card data. So it should be reasonably secure. Here's what I've come up with. I'd appreciate any constructive criticism. <...
0
votes
0answers
39 views

Stream wrapper for base 64 string

We have a scenario where we are receiving file as base64 string. This is not ideal and should be a binary stream. Because with file size memory utilization grows very rapidly as base64 representation ...
1
vote
1answer
39 views

Small service for hashing and validating passwords, using PBKDF2

As part of a larger authentication/authorization system, I've developed a small .NET Core 3.0 service for hashing passwords using PBKDF2 (with a salt) and validating passwords against a stored hash/...
2
votes
0answers
128 views

Seekable HTTP response stream wrapper

I created this wrapper to use together with HttpClient streams and ZipArchive. ZipArchive ...
19
votes
4answers
3k views

Matrix class in C#

I've been learning C# during my free time in the past months; before that, I was mostly writing Java, so the transition hasn't been too hard, but I've never had my code reviewed or read by someone ...
3
votes
2answers
117 views

Parcel size classifier [closed]

I submitted a technical assignment for a job interview process and I am stressing out wondering if my submission was any good. I would like to learn and be a better developer, so please give me ...
-1
votes
1answer
50 views

Reduce CPU utilization in constant pinging to API and saving data in to database service [closed]

I have this hosted service which grabs the data from API every second and process the data and save it into the database. I have similar 3 more hosted services which run at the same time. Because of ...
2
votes
1answer
82 views

Hosted service which perform CRUD operations in high update environment

I have this hosted services which garbs the data from the API and save it in the database. But before saving it checks if the data already exists in the DB if not it creates the new row and if it ...
4
votes
2answers
147 views

DropDown tree with search

I fetch a bunch of categories for a DropDown tree, and have to implement search in this dropdown. If there is a match in one of the elements, it should also get all ...
2
votes
1answer
44 views

Posting images from request to Azure blob

I have base Controller for Attachments, here is code of it In this controller, I pass data from the request and return URL of the posted object. ...
1
vote
0answers
67 views

What pattern can I use to write CRUD functionality? [closed]

I am writing a console application. CRUD functionality.I would like to try to apply the pattern. Is it possible to apply a "state" pattern? In the AddCustomer () ...
3
votes
1answer
117 views

Capsulation solution for byte arrays

In a part of the project, I had to implement a solution for encapsulation of byte arrays. We do use ssh and secure ports for socket connection but I was in need of an extra layer of protection against ...
8
votes
2answers
1k views

ROT13 encoder/decoder

This is a simple utility, intended to sit on the desktop for when needed, that does the simple ROT13 encoding and decoding. I am used to coding in VBA, and I am interested in more .Net idiomatic ...
3
votes
1answer
299 views

Compare performance of Concurrent Dictionary with Dictionary+Locks

I wanted to measure the performance of Concurrent Dictionary vs Dictionary+Locks in a multithreaded environment. So I created my own SyncDict class of type...
6
votes
2answers
794 views

Safe Dispose of Timer

I am currently refactoring a larger solution where the compiler gave multiple warnings about disposing the used System.Timers.Timer instances. The timers are ...
3
votes
1answer
61 views

Calculating all flight connections

I am working on an API to return all the possible flight route between point A and B. I have a set of data which includes the flight number, airline, departure airport, destination airport, departure ...
1
vote
1answer
199 views

Do these BLL-DAL comply with the Dependency-Inversion Principle and is this valid Dependency Injection?

I am working on a very simplified proof of concept (POC). Separation of concerns should be achieved in this project, so that in the future we have flexibility in respect of what data source we use (...
7
votes
3answers
541 views

Compiling all Exception messages into a string

Below is a recursive function I've written that's responsible for compiling a string consisting of a Exception's message, and also each of that ...
1
vote
2answers
257 views

Get value from a dictionary contained in a dictionary

I have an API that returns a dictionary of dictionaries. I currently have this code to access the value of the dictionary, but it looks like a code smell. Is there a better way to structure this? <...
3
votes
0answers
73 views

msmq bulk send in c# [closed]

Please review the code below and provide constructive feedback to improve. Multiple threads call the SendMessageToMSMQ method to send messages to a msmq queue. ...
2
votes
1answer
85 views

Should I re-throw exceptions within a method, or is there a better way to handle it? [closed]

When handling errors in C#, is it acceptable/appropriate to re-throw exceptions that are caught in a try/catch? My scenario is that I am making an HTTP request and ...
1
vote
2answers
109 views

Object-oriented implementation on Expense Tracking App [closed]

I am creating a Expense Tracking Application in C# and right now I am trying to build its building blocks in a console app. I Would like to know your feedback if it is in a Object Oriented Design/...
5
votes
1answer
83 views

Rate limiting variable-duration operations over a time interval

I want a rate-limiter that permits, at most, N operations over T seconds. I found a sample implementation here but it makes an assumption that operations complete in a predictable, consistent amount ...

1
2 3 4 5
22