Questions tagged [c#]

C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

243 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
1answer
413 views

Clarification about Event Producer in StreamInsight

I need a small clarification about StreamInsight, I know by doc's that StreamInsight can handle multiple concurrent Events. But will the event producer be a separate function, for ex: I need to watch ...
6
votes
0answers
4k views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here: https://app.pluralsight.com/library/courses/tactical-design-patterns-dot-net-control-flow/table-of-contents ...
5
votes
2answers
2k views

Should AutoMapper be used to Map from ViewModel back into Model?

Should AutoMapper be used to take data from ViewModel and save back into a database model? I know the opposite practice is good software practice: to have Automapper to extract database models, and ...
4
votes
0answers
105 views

Dictionary-Sorting in bigger projects

My concern is how to handle ResourceDictionarys in a WPF (MVVM)-Project. I usually only create small Projects, so it doesn't matter that much, but since I created a Project-Template to handle some of ...
4
votes
1answer
850 views

Writing a Compiler - .reloc section of the COFF

I'm looking for a little bit of direction in writing a compiler. I've written in Common Intermediate Language, C#, and various other .NET languages; I've written my own Metadata Parser and now I'm ...
4
votes
0answers
1k views

Enforce No Multiple Async Entity Framework Operations

We are working on a large-ish MVC web application with multiple backing stores including a SQL Server database accessed via Entity Framework 6.0. We are using asynchronous operations wherever we can, ...
4
votes
0answers
451 views

Separate settings and implementation class hierarchies

We use XML serialization to store class settings. Each setting-class has (but doesn't reference) corresponding implementation-class. Therefore we can easily make a "settings dll" without any ...
4
votes
0answers
2k views

Any “Gotchas” to using Entity Framework for Identity & Dapper for all other DB access in a .NET MVC application?

I'm firing up an MVC project in which I'd really like to use Dapper as my ORM, as I like to be as close to the database as possible for performance and SQL tweaking reasons, yet still have the power ...
4
votes
1answer
5k views

Unit Of Work with multiple database context

I have created an application (net core 2 & ef core) with Unit Of Work and Generic repository pattern. I used to have one database context but due to some business logic I had to create a second ...
4
votes
1answer
242 views

.NET DataSource binding for legacy SQL Server DB with undefined relationships

I'm designing a utility that will load data into a legacy SQL Server Database. I've been trying to mock up a simple WinForms utility with C# using the DataSource connectors (Tried a straight ORM ...
3
votes
3answers
162 views

Should an interface be defined in the infrastructure layer if it's only used by an implementing class in that layer?

Overview If an application is being developed following a clean architecture / DDD approach, my understanding is that the application core or domain layer should contain classes and interfaces that ...
3
votes
0answers
107 views

Daylight savings time for real time application

I am building an application on windows forms C# that will run in real time 24 hours a day 365 days a year. This application tracks the time that components are out of storage. I am running into a ...
3
votes
0answers
75 views

How should domain model entities expose information about the current state of their properties?

I'm new to DDD, so please bear with me. I am trying to design a domain model around an extremely large and complex existing system, where most of the current "domain" logic is either in the UI or in ...
3
votes
0answers
41 views

Can the read api receive events that the write api does not receive or raise?

Say I have a read API and a write API: MyApp.Write.api MyApp.Read.api Both API's handle integration events from other apis/microservices. Say I had certain integration events that only need to be ...
3
votes
0answers
100 views

Should I use gRpc in my business layer?

I'm moving from REST APIs to gRpc but having a hard time figuring out how to structure my logic. The basic layout of my solution is having a business layer/API and a few different front-ends (Windows ...
3
votes
2answers
191 views

Queueing async code to execute later

I have a website with basic crud operations that involve data and photos. I also need to extract the metadata for the photos that are being uploaded. My original implementation did not have var puts =...
3
votes
0answers
255 views

LSH for a wordlist

I am trying to write a spellchecker, I have a huge wordlist (at least 500K, because of the nature of the language). The performance would suffer a lot if I got the lavenshtein distance of all of the ...
3
votes
1answer
279 views

Using Active Directory ObjectSid as Primary Key in SQL Server for Data Access via ASP.NET MVC

I am designing an Intranet employee reward web app using ASP.NET MVC C#/MS SQL Server. This will only be accessed from within the network. Employees and managers will be able to give a reward to ...
3
votes
2answers
380 views

Propagating Data to multiple ViewModels - C#

I'm a bit new to MVVM, but here's my dilemma: I have a model (or models, but let's keep it simple) I want to show that model data on multiple different views. Ok, so ViewModel for each view gets ...
3
votes
0answers
279 views

Displaying entity framework calls in Sequence Diagram

I have a controller action which gets all the Plants by location from the database puts it inside a view model and passes it to the view. public ActionResult index() { List<Plant> plants = ...
3
votes
2answers
2k views

Adding model into another view model's collection

The Setup So I'm working on a project in which there exists a MainViewModel class. This MainViewModel contains a list of Soldiers through an observable collection. I have a button in the MainView ...
3
votes
0answers
142 views

A / B testing without seperate deployments

I am part of a development team producing a project which requires many rounds of iterative development, each of which must be user tested, frequently in an A/B kind of environment. In our deployment ...
3
votes
0answers
147 views

C#: simulate PostScript memory allocation

I'm working on a PostScript interpreter in C#. PostScript has memory management. It has virtual memory (VM). It also has objects. Two types of objects: simple and composite objects. Composite ...
3
votes
0answers
768 views

Reading and saving big data to db

I have a method for reading data from file. The problem is how to handle files that are too big for a simple read and save to database? I was thinking about reading a chunk of it and saving it to ...
3
votes
0answers
939 views

Traditional installer for a WinForms application

What is the preferred method of creating a "normal" traditional installer for a .NET WinForms application? I'm using VS 2015 which comes without a template for such a deployment project. I installed ...
3
votes
0answers
407 views

Multiple Entity Business Logic/Changes, C# MVC Repository Pattern

I have a standard C# MVC project which has a domain layer using EF and repository pattern. Say I have a model like: public class MainModel { public int MainModelID {get; set;} //Many other ...
3
votes
0answers
618 views

Creating a generic Cache solution for function calls using SOLID principles in C#

I would like to have a caching solution for a variety of function calls. All of the function calls fit the following signature public ResponseType ProcessRequest(RequestType request); About half ...
3
votes
0answers
2k views

Generic Type Parameters where one is itself Generic with a Type Parameter of the Other

I have a couple of classes with the following pattern that I am uncomfortable with. Is this the only way to do this, or are their other design patterns that would be more reliable. public class ...
3
votes
0answers
721 views

Correct Class Design for EAV Model

I need to design a class model to represent an EAV Model. I based my classes on this presentation http://www.slideshare.net/stepanyuk/implementation-of-eav-pattern-for-activerecord-models-13263311?...
3
votes
0answers
1k views

How to Use Python as a “Macro” runner for a C# Application

I am working on an application that the user may wish to automate some features of (but we don't know what at the moment) I would like to provide them some kind of scripting interface so they can play ...
3
votes
0answers
4k views

Should UserControl's be Views in an XAML MVVM application (WPF or Store app)?

I am about to use Caliburn.Micro for a new XAML Store app (not sure what to call it nowadays - does not appear to be called a "Windows Store app" any longer). The documentation (see Simple Navigation ...
3
votes
0answers
1k views

TryUpdateModel vs Parameter and ModelState.IsValid

As I was originally learning about MVC, the book I was using taught the following technique for Controller actions: public ActionResult MethodName(Model model) { if (ModelState.IsValid) { } ...
3
votes
0answers
824 views

An efficient way of starting an arbitrary number of consumer threads?

I have a Producer/Consumer implementation where the number of consumers is configurable (this is a form of configurable throttling). The producer and consumer are kicked off like this: var cts = new ...
3
votes
0answers
529 views

State Pattern Code for embedded device - Dependency Injection of Device Objects in Context and State Classes

I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events. I've got a simplified system that will work like this: This is my first go with State ...
3
votes
0answers
347 views

Match buyers and sellers based on date ranges and quantity of shares

NOTE: This is in reference to the question I asked on Stack Overflow but was told to post this here I'm building a trading application that matches buyers/sellers that own subscription. Subscriptions ...
3
votes
0answers
772 views

ASP.NET Mvc3 - application/request lifetime and dependency injection

I thought of asking on SO, but it seems this is more of a "concept" type question than a "problem" type question. If it needs to be moved, please do so. Anyway, I'm having a tough time finding ...
3
votes
1answer
1k views

Is it a bad practice to subscribe to an event with an Action

I use a third party library for speech recognition. This library give me access to some classes ( SpeechRecognitionEngine, SpeechRecognitionConfiguration etc) which give me access to some events (...
2
votes
3answers
158 views

What is an good way to conditionally update a property on a collection of objects?

I have a collection of Shipment objects that I am iterating through to update another system. A property on a Shipment is a Stockroom. The target system has a unique ID defining a Stockroom record. If ...
2
votes
0answers
56 views

Efficient BACnet device polling strategy

Example BACnet network: Some help is needed to solve a problem around architecting an efficient method of polling BACnet devices across multiple networks (i.e. MS/TP networks) where client software ...
2
votes
0answers
179 views

Onion Architecture: Should Service Layer contain DB Context?

In Onion Architecture, we have repository layer which conducts Crud Operations (simple insert, delete, update). (Applying Entity Framework with database) Onion Architecture Additionally , we have ...
2
votes
1answer
108 views

Is making your ORM DAO a subclass of your Domain Model object a viable strategy?

I am trying to separate my domain model and associated business logic from my persistence model, particularly such that the domain model has no dependency on the ORM. One apparent way to do that was ...
2
votes
2answers
168 views

Wrapper Class Should be made static?

I am planning on creating a wrapper class in c# which will call cryptographic functions provided by .Net Framework, just to make sure I am clear, I am not writing any cryptographic algorithm, just ...
2
votes
1answer
108 views

How to populate view models

So let's say I have a view model, representing a student. The view model is corresponding to a student model, from which the data comes. What I am struggling with, is how to populate the fields in the ...
2
votes
0answers
46 views

Event Sourcing & Redis

I'm using StackExchange.Redis library, it seems perfect. Hard-coded events related BankAccount with ID 1: // UNSORTED COLLECTION public static List<Event> DomainEvents = new List<Event>()...
2
votes
0answers
62 views

Extending IdentityUser with nullable foreign key to another IdentityUser

I'm working on a framework which builds on .net core Identity. Let's say I wanted to extend the IdentityUser<TKey> class with a ParentUserId property while the developer should still be able to ...
2
votes
0answers
74 views

What's the best way to control distribution/usage of proprietary, internal software?

I was tasked with writing software for my company. As I am now writing a third program (with many more coming), what's the best way to control the distribution/usage of our software? The software I'...
2
votes
0answers
79 views

Is there a name for this Registry-Slot-Updaters pattern?

I noticed a pattern in my code. It applies to situations where things can be selected. It revolves around classes which I call (and in code often suffix with) Registry, Slot and Updater. Registry ...
2
votes
0answers
287 views

Replication between SQL server and Couchbase Lite

We have a main MS Sql server. This is the main data source that delivers and receives data to and from backend administration and (in development) mobile software. We need to make a connection to ...
2
votes
0answers
167 views

Proper pattern to use when sharing large amounts of code and a similar control flow?

So I'm currently building an application that allows a user to fill out paperwork digitally, and then that information is taken in by the server and a PDF is populated and returned to the user. The ...
2
votes
0answers
209 views

Data pipeline with fallbacks and callbacks

I'm refactoring our current design for how we download static data. It's a mess of deep class hierarchy and callback hell and I want to convert it to a more elegant straightforward design. Here are ...