Posts by Marcell Alves • 2,453 points
66 posts
-
3
votes2
answers39
viewsA: How do I display an Object type variable on the screen through Alert?
To show the object structure as text, you can use the function JSON.stringify, follows an example below: let carro = { modelo: "corsa", marca: "chevrolet", aVenda: true };…
javascriptanswered Marcell Alves 2,453 -
0
votes1
answer217
viewsQ: Quit git log or git diff
I turned the remote git log and visualized all the content, until reaching the end according to the print: However, I can’t do anything else in this terminal window. I’ve tried writing exit, type…
-
0
votes1
answer217
viewsA: Quit git log or git diff
What happens is that git loads a program less, that allows the log to be scrutinized. To exit this program, simply type q. To objter help, type h…
-
5
votes1
answer500
viewsQ: What is npm @types and how do they work?
I’m starting a project with NodeJS and TypeScript and the instructor told to install the @types/node, beyond the npm package TypeScript. He quickly quoted that the @types/node creates types in the…
-
1
votes1
answer48
viewsA: Understanding how it works to convert an Object to Json
What happens in this case is that C# is a typed language and its JSON object is just a string until the serialization process occurs, that is, convert this JSON text to a typed C object#. What the…
-
1
votes3
answers289
viewsQ: Set NODE_ENV via command line on Windows
I am taking a Node.JS course the instructor executes the following command to change the environment variable NODE_ENV: NODE_ENV=production node index.js However, this command only works on Linux.…
node.jsasked Marcell Alves 2,453 -
0
votes3
answers289
viewsA: Set NODE_ENV via command line on Windows
To set the environment variable and run the Node application with a single command on Windows, we can install the npm package win-Node-env as a global dependency: npm install -g win-node-env…
node.jsanswered Marcell Alves 2,453 -
3
votes1
answer4561
viewsA: How to send FORM values to the Controller in ASP.NET MVC?
A simple Submit is enough for this scenario. I recommend using the html helper BeginForm MVC for form generation: @using(Html.BeginForm("ShowClients")) { <input type="text" id="proc" name="proc"…
-
4
votes3
answers546
viewsQ: Convert char to integer in C#
Reading a blog article, I came across the following syntax for converting char to integer: string value = "123"; foreach (var c in value) { if (char.IsDigit(c)) { int digito = c - '0'; } } I wonder…
-
1
votes1
answer104
viewsQ: Dataconnectiondialog giving error in Visual Studio 2017
I’m migrating to the Visual Studio 2017 a legacy project that uses a modal window to collect database connection data and format a string connecting. The code below shows an error: var dialog = new…
-
2
votes1
answer3402
viewsA: "TS1005: ';' expected" error when compiling class with Typescript
The problem was occurring by using the version 1.0.3.0 typescript. To troubleshoot the problem, I needed to uninstall the package being used (npm uninstall -g typescript) and install the latest…
-
2
votes1
answer3402
viewsQ: "TS1005: ';' expected" error when compiling class with Typescript
I am studying Typescript classes through official documentation: https://www.typescriptlang.org/docs/handbook/classes.html. I used exactly the same example code as the documentation: class Greeter {…
-
3
votes1
answer60
viewsQ: Why are boolean values converted to string in the case Camel in C#?
Today I came across a peculiarity of C# which I had never stopped to pay attention to: When converting a value bool for string, the result is a text in Camel case: string verdadeiro =…
-
1
votes1
answer167
viewsA: Error Running a query with npgsql + Dapper in postgresql
Your query defines two parameters: @Login and @Senha. They need to be passed through an anonymous object in the method Query: public Usuario Login(Usuario user) { return…
-
5
votes2
answers130
viewsA: How to concatenate variable with empty object (between keys)?
$objeto = {}; $objeto.conteudo = []; for(var i = 1; i < 4; i++) { $objeto.conteudo.push({"dado":"" + i}); } console.log($objeto.conteudo); $objeto = {}; $objeto.conteudo = "dado";…
javascriptanswered Marcell Alves 2,453 -
1
votes2
answers254
viewsA: CRUD with images , working with Httppostedfilebase and byte[]
For security reasons, you cannot set a file as value in a field <input type="file"/>. What can be done, in this case, is to put a if in his view. If the file exists on model, you render a tag…
-
1
votes3
answers269
viewsA: Click a buttom and a prompt appears
Alternative solution using a button: function confirmaSaida() { var confirmado = confirm("Deseja realmente sair da página?"); if (confirmado === true) { self.location = "https://www.google.com"; } }…
javascriptanswered Marcell Alves 2,453 -
0
votes2
answers54
viewsA: How to sort the DATA of the Jquery url
Assuming data is a array, you can use the method sort() javascript: retorno.data.sort(function(a, b){ return a.nome > b.nome; }) Reference: https://www.w3schools.com/jsref/jsref_sort.asp Example…
-
2
votes2
answers1054
viewsA: Show and hide DIV according to user level
A very general implementation could be: function exibirDivDeAcordoComNivelDoUsuario(usuario) { if(usuario.nivel !== 1) { document.getElementById("hmn0").style.display = 'none'; } }…
javascriptanswered Marcell Alves 2,453 -
8
votes3
answers370
viewsQ: Private set of property in an interface
I’m modeling a C# interface that has a property. However, I want to ensure that all classes that implement this interface maintain the Setter as private: public interface IBar { string Id { get;…
-
8
votes1
answer618
viewsQ: Why does the reduced version of git SHA1 code have 7 characters by default?
I’m studying Git and came across the command cherry-pick, who recovers a commit specific. The parameter passed for this command is the code hash generated to identify only that commit. However, in…
-
8
votes1
answer156
viewsQ: What are symbols in the . NET Framework?
How do symbols work in the . NET Framework (and other platforms)? How do they make it possible to debug application even without having the source code on the machine? What is your relationship with…
-
0
votes2
answers487
viewsA: Create an element with a list of user-informed values
For item deletion functionality, I suggest entering a link next to each of them, and writing a function that removes that specific item: var menu_dropdown = document.getElementById("selecao");…
-
1
votes2
answers487
viewsA: Create an element with a list of user-informed values
You can solve this problem by dynamically adding items to a list of HTML (ul / li): function Enviar1() { var ul = document.getElementById("itens"); var li = document.createElement("li"); var valor =…
-
0
votes1
answer3155
viewsQ: How to clear Windows Python interpreter screen?
I’m starting to study Python (version 3), doing several syntax tests using the interpreter for Windows. However, I would like to clear the commands I have already executed from the screen as the…
-
0
votes1
answer249
viewsA: Visual Studio Code breaking Jekyll’s page layout
The problem was occurring because of the extension: JS-CSS-HTML Formatter. So the solution was to edit the file formatter.json and set the property onSave for false. To do this, I followed the…
-
8
votes3
answers722
viewsQ: Initialize private fields in the declaration or constructor?
I’m modeling a class that has a private list and an internal dependency on another object: public class Teste { private IList<string> Textos; private Teste2 Teste2; } I can initiate them in…
-
1
votes2
answers355
viewsA: Error 1 The type or namespace name 'Datareader' could not be found (are you Missing a using Directive or an Assembly Reference?)
The method ExecuteReader() returns a SqlDataReader: using (SqlDataReader reader = cmd.ExecuteReader()) { }
-
3
votes2
answers35
viewsA: Notsupportedexception error when setting value to a Datasource
You need to materialize the return of the database data through a conversion to an object or collection. Following the suggestion of the error message, try calling the method ToList() after applying…
c#answered Marcell Alves 2,453 -
1
votes2
answers232
viewsA: Inheritance with Entity Framework
An alternative implementation for your case would be to create a mapping class and use the Ignore for properties you don’t want to map to the bank: Mapping class: using…
-
2
votes3
answers572
viewsA: What is map / reduce?
Examples in C# with Linq: Map, using the method Select: var arrOriginal = new int[] { 1, 2, 3, 4, 5 }; var arrFinal = arrOriginal.Select(n => n * -1); Map Example in . Net Fiddle. Reduce, using…
javascriptanswered Marcell Alves 2,453 -
11
votes3
answers572
viewsQ: What is map / reduce?
Map / Reduce is a very common concept in JavaScript and many other languages. What it means and how it works in practice?
javascriptasked Marcell Alves 2,453 -
0
votes1
answer249
viewsQ: Visual Studio Code breaking Jekyll’s page layout
I’m editing a file HTML from my blog’s Jekyll in the Visual Studio Code: However, when saving the file, Visual Studio Code puts the page layout reference text in only one line, breaking the…
-
6
votes4
answers1350
viewsA: How to pass string by reference?
In C#, string is, yes, a type by reference. Strings in C# are immutable, that is, you never really change the value of a string and yes gets a modified copy which is then assigned to a variable.…
-
7
votes4
answers977
viewsA: Separate repeated values in a list
The function Distinct of Linq deletes duplicate data from a list in . Net Framework: var lista = new List<int> {1,1,1,2,2,1,5,3,4,3,4}; var listaSemDuplicidade = lista.Distinct(); A functional…
c#answered Marcell Alves 2,453 -
7
votes2
answers1557
viewsQ: Does Node.js compile the Javascript that runs on the server?
According to V8 documentation, it compiles Javascript for machine code, as an optimization strategy. Thus, the Javascript that runs on the server via Node.js is compiled or interpreted?…
-
5
votes1
answer248
viewsQ: What is managed code?
In a conversation with a co-worker about what language was used to develop Windows, he said that many parts should still be developed in C and C++, as it was necessary to run unmanaged code. Other…
-
0
votes1
answer3284
viewsA: Add and remove required Jquery
Follows a functional implementation: $(":radio[name='dirar']").change(function(){ if($(this).val() === "0") { $(":radio[name='isubrar']").attr("required", "required"); } else {…
-
1
votes1
answer51
viewsQ: What is the safest way to test whether a data-* attribute exists?
I need to test if a date-* attribute exists in an element and if that attribute is filled with some value: <input type="text" id="teste" data-validationMessage="Esse campo é obrigatório" />…
javascriptasked Marcell Alves 2,453 -
0
votes1
answer43
viewsA: Kendo Multiselect passing placeholder as search value
The error was in the way to recover the entered value in MultiSelect. The correct is to use the array filters of the object filter passed as parameter in the event data. The corrected Javascript…
-
9
votes2
answers2912
viewsQ: What is the purpose of the Gethashcode() method?
I’m using Resharper to automate the method override Equals and the operator ==. One of the methods the tool has overwritten is GetHashCode: public override int GetHashCode() { unchecked { return…
-
6
votes5
answers12535
viewsA: Why is Varchar(255) widely used?
Varchar(255) is widely used because it is the default value and many developers keep this value non-stop to wonder if it really takes 255 characters to store that information. I do not see as a…
-
0
votes1
answer43
viewsQ: Kendo Multiselect passing placeholder as search value
I have a form with a component Kendo UI Multiselect for ASP.NET MVC / Razor: @(Html.Kendo().MultiSelectFor(m => m.Ids) .Filter(FilterType.Contains) .AutoBind(true) .MinLength(3) .Delay(500)…
-
1
votes2
answers70
viewsA: How to use Contains without capitalization and minuscule
There are two other alternatives: 1 - Using ToLower or ToUpper: result = result.Where(l => l.Example.ToLower().Contains(search.ToLower())).ToList(); result = result.Where(l =>…
-
2
votes4
answers8945
viewsA: What’s the importance of indenting the code?
Identation is a fundamental resource for the readability of a code, as it adds important information, such as: which block of code belongs to a function or method? It also helps to understand the…
indentationanswered Marcell Alves 2,453 -
1
votes1
answer39
viewsQ: Why do navigation properties need to be declared virtual?
I’m mapping a relationship 1 x N using a class POCO (Plain Old CLR Object) to be used with the Entity Framework 6. In this case, I own an entity Cart which has several Products: public class…
-
7
votes2
answers459
viewsA: Represent relationships in json
The correct is the object enterprise possess a array object representative, which in turn has a array object contract: { "empresa": { "empresa_id": 1, "nome": "Empresa 1", "representantes": [{…
jsonanswered Marcell Alves 2,453 -
1
votes1
answer828
viewsA: A specified Include path is not Valid. The Entitytype 'Model.User' does not declare a navigation Property with the name 'Connections'
To navigation Property "Connections" should be declared as virtual: public partial class User { public string UserName { get; set; } //Adicionei esse novo código abaixo: public virtual…
-
5
votes1
answer789
viewsQ: Use Ienumerable or Icollection?
I want to create a 1 x N mapping using the Fluent API of Entity Framework, something like: a shopping cart has several products. In my class stroller, I have a navigation Property, which is a…
-
1
votes2
answers3207
viewsA: Creating table with Primary key ID column with auto increment
The creation script for SQL Server would look like this: CREATE TABLE dbo.Persons ( ID int NOT NULL IDENTITY (1, 1), LastName varchar(255) NOT NULL, FirstName varchar(255) NULL, Age int NULL ) ON…
sql-serveranswered Marcell Alves 2,453