Should I use entity framework for CRUD and let the database handle the complexity that comes with high end queries?

I am new to ef and liking it since it reduces the overhead of writing common queries by replacing it with simple add, remove functions. Agreed.

Today I got into the argument with my colleague who has been using it for a while and approached him for advice on when to use Stored Procedures and when to use EF and for what?

He replied;

Look, the simple thing is that you can use both but what’s the point of using an ORM if you are doing it all in database i.e. stored procedures. So, how would you figure out what to do where and why? A simple formula that I have learned that use ORM for all CRUD operation and queries that require 3-4 joins but anything beyond that you better use stored procedures.

I thought, analyzed and replied;

Well, this isn’t the case, I have seen blogs and examples where people are doing massive things with EF and didn’t need to write any procedure.

But he’s stubborn and calling it performance overhead which is yet beyond my understanding since I am relatively new as compared to him.

So, my question is that whether you only need to handle CRUD in ef or should do a lot more in EF as a replacement of stored procedures.

How to handle phalconphp GPG issue

I’m trying to update my nodejs installation, and phalconphp is getting in the way. When I run apt-get update, I get this complaint

Err:13 xenial InRelease                                           The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4166E80CDCF8B31B 

Following the advice of several threads (such as this one, I’ve tried to fetch the GPG key:

sudo gpg --keyserver hkp:// --recv 4166E80CDCF8B31B 

Results in

gpg: requesting key DCF8B31B from hkp server gpgkeys: key 4166E80CDCF8B31B not found on keyserver gpg: no valid OpenPGP data found. gpg: Total number processed: 0 gpg: keyserver communications error: key not found gpg: keyserver communications error: bad public key gpg: keyserver receive failed: bad public key 

So how do I figure out which server should have the GPG key?

how to let mincost flow problem handle lower bounds

For the mincost flow problem formulated in this slide:

Given directed graph G = (V, E)

  • Let u denote capacities
  • Let c denote edge costs.
  • A flow of f(v,w) units on edge (v,w) contributes cost c(v,w)f(v,w) to the objective function.

  1. Send x units of flow from s to t as cheaply as possible.

I noticed that there is only upper bound on each edge (v,w) in the above formulation, as with the other formulations presented there. In my application, I need to impose lower bounds on each edge.

Is it possible to transform the extended min cost problem with lower bounds ‘l’ to the basic form above?

I found some transformations here for the max flow problem. But it does not seem to consider cost, and does not apply to the above problem.

How to handle role based access in my microservice architecture

We are trying to move from a monolith application to a microservice architecture faced by a spa application. One of the reason, is that we want to expose some services of our business to partners and another reason is to build a better user experience via an spa application.

In the old application I had a webapplication where I could register an employee (name, surname, empno, adress…), choose his company from a dropdown list and in the same time create an account for this employee in a backend erp : think of this application as a backoffice one. All data was on a single form, when the user submit the form : the backend server save the employee record, and if successful create an account in the erp system.

In order to manage the authorization for this application : the url to register an employee in the webapplication was accessible only if the loggued user have a role that able to handle the “RegisterEmployee function”.

Now in my spa application, I need to call :

  • a microservice for verify if the employee is not already registered ,
  • a microservice to have the list of the known companies
  • a microservice to create the employee account in our erp

I was first trying to define the roles allowed in each microservice, but it seems weird because : – all my microservices could be reused in different scenarios – and they don’t necessary share the same list of roles…

I had read about api gateway lately, and perhaps it is the way to go, but I am not sure how ? Does this mean that my microservices do not have to be aware of any authorization management ?

How should I handle a change in monthly rent with Budgets on Mint?

Let’s assume today is Jan 1st and I’ve started the year with a total budget of $ 4,000/month. My rent is currently $ 1,000/month, and so the other budget categories add to $ 3,000/month. In March my rent will jump to $ 1,200/month. I want my total budget to stay at $ 4,000/month, so starting in March I’ll need to increase my rent budget to $ 1,200, and decrease my other budget categories by $ 200 total.

I’ve enabled the checkbox for “Start each new month with the previous month’s leftover amount” because that’s a nice way of handling month-to-month fluctuations in expenses. I’d of course like these running totals to carryover into March.

How do I do this (or something like this) in Mint?

How to handle events consumed by multiple threads from a queue that require a specific order

I have a TCP Server that produces three kinds of events:

1) Connected (Socket)
2) Received (Socket, Data)
3) Disconnected (Socket)

these events are pushed into a queue. There are multiple threads that consume this queue.

A order of events might look like this:

1) Connected(Socket1)
2) Receive(Socket1, Data1)
3) Connected(Socket2)
4) Disconnected(Socket1)

I want to do some initial setup only once when a socket connected (wrap it in a custom class and add it to a lookup table) so when the receive event happens I can find my custom object which has some state attached to it and operate on the data.

So now you can already see if there are more than 1 thread consuming the queue, the order might not be preserved, so that Thread2 would handle a receive call before Thread1 handled a connect call.

What would be a good way to ensure that receive is only handled after connect was handled?

How to handle multiple save states on mobile?

I have a mobile app that I am working on that allows an account owner to manage subscribers on the account. From one screen, they will be able to set “limits” using a slider on the account. Each input/action from the account owner is a service call.

The initial UI was a batch edit and save mode where all the changes are made and one service call is made. The issue with this flow is that since everything is its own call, some elements could potentially fail and some pass which would mean multiple success/alert notifications at a time.

So the alternative is a save state for each individual subscriber where we force the user to pay attention to each individual save to make a change.

enter image description here

Does anyone know of a better experience in this case?

How to handle check-able tree-view nodes that act as both a group and an item

I need to create a tree-view which allows users to select nodes (using a checkbox). The tree-view contains two types of node, “group” and “item”. A “group” node can contain both “group” and “item” nodes. An item node can’t contain other nodes. Crucially selecting a group node should automatically select all node below it (to the bottom of the tree).

However, due to this last criteria I can’t figure out the following behaviour (I make reference to the attached diagram).

  1. The user selects Group A
  2. Now Group A, Group B, Item 1 and Item 2 are now checked.
  3. The user then deselects Item 1

What should the state of Group A be (checked, unchecked or indeterminate)?


How to handle different pages of a web application having different levels of access to a database model

I am working on an ASP.NET Core application that grabs a model from a database via Entity Framework, and will pass a “subset” of that model to our Angular front end. For example:

I have a list of Users. On the user-list page, I would like to grab a list of User objects from the API and display them on the page. For each User, it should only show Name and maybe a few other fields.

I would also like to be able to click on the user’s name to redirect to their profile page. On this page, we will get more fields from the User table – perhaps more in-depth information like Nickname or Middle Name, etc.

My question is, what is the “correct” way to structure this, on the front-end side and the server side?

On the front end, is it best to have one class with nullable values that either get filled out or left null based on which page they are on? Like this:

export class User{     firstName: string;     middleName?: string;     lastName: string; } 

Or would I have “UserListUser” and “UserProfileUser” classes that are completely separate? Or, would it be a parent class called “User” with a subclass with more information like “UserFull”?

And, on the back-end, is it best to do the same thing? Would you create separate classes for each page that has access to that database model? Would you just use the ORM object that is created from Entity Framework? Or would you always map that to a smaller object with only a subset of the fields on the database table?