Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
2
votes1
answer39
viewsA: SQL server 2012, ex fix
I rode this Fiddle for you. Returned the following: cli_nome -------- Beltrano Ciclano Ciclano As it had repetition because of the products, we need to use DISTINCT to bring each name only once, so:…
-
3
votes1
answer1200
viewsA: Obtaining data from excel and turning it into a list by Python
There are several errors in this code. The corrected version would look like this: import xlrd def ler_arquivo(): tt1 = xlrd.open_workbook('teste_termal1.xls', formatting_info=True) eajp60 =…
-
3
votes1
answer1563
viewsA: How to sort sql columns in alter table
Yes, only by SQL Server Management Studio. By Transact-SQL this is not possible. For the database, the order of the columns is irrelevant. This functionality can even be considered cosmetic, since…
sql-serveranswered Leonel Sanches da Silva 88,623 -
4
votes2
answers938
viewsA: How to join lists in c#?
Yes: foreach (var produto in listaProdutos) { produto.Departamento = listaDepartamentos.FirstOrDefault(d => d.DepCodigo == produto.DepCodigo); } I suppose listaProdutos the list of products and…
-
5
votes1
answer346
viewsA: Problems generating a Partialview with Begincollectionitem
Quickly solving the problem, it would be something like this: <div class="form-group col-lg-12" style="margin-bottom:30px;"> <label>Experiência…
-
14
votes3
answers29788
viewsA: Measuring the run time of a function
You can use time.time(): import time inicio = time.time() funcao() fim = time.time() print(fim - inicio)…
-
3
votes1
answer21806
viewsA: Read rows and columns by Python, by excel
Yes, there is the package xlrd who reads Excel files for you. Example: import xlrd book = xlrd.open_workbook("meuarquivo.xls") print "Número de abas: ", book.nsheets print "Nomes das Planilhas:",…
-
2
votes1
answer32
viewsA: SQL Server 2012, doubts
Yes, but I would put all the prefixes to avoid ambiguities: select p.ped_numero, i.ite_precounitario, pr.pro_preco from pedido p, item i, produto pr where p.ped_numero = i.ped_numero and…
-
1
votes1
answer255
viewsA: How to write data in one table for many?
Your question is another of the classic questions that ask the use of Begincollectionitem, but there are some addendums to be made. The naming convention of Models usually it is in the singular,…
-
7
votes3
answers16306
viewsA: Validate Credit Card Number
Validation of credit card numbers is usually done by Luhn’s algorithm: Remove the last digit from the number. It is the checker; Write the numbers in reverse order; Multiply the odd digits by 2 and…
-
4
votes1
answer1218
viewsA: How to run a query with large data volume?
For these cases, the way is to use the command prompt or Powershell and run the script using: > sqlcmd -S COMPUTADOR\INSTANCIA -i .\MeuScript.sql -d MeuDatabase Usually I run like this: >…
sql-serveranswered Leonel Sanches da Silva 88,623 -
5
votes1
answer61
viewsA: Run a method when Webservice is Started
Make your static method in a separate class. For example: public static class Inicializacao { public void RecuperarAposFalha() { /* Coloque aqui os passos para recuperação. */ } } Call the method in…
-
2
votes1
answer338
viewsA: I can’t download a file by Actionlink mvc5
You are on the right track. Let’s just modify a few things: Here: public FileResult Download(int id) { int _arquivoId = id; var arquivos = oModelFiles.GetFileReport(id); string nomeArquivo = (from…
-
5
votes1
answer67
viewsA: Convert string to function
This is the incredibly wrong way to do what you want. You want to define a function at runtime, which is interesting, but not by String that you must do this. The right thing to do is to use…
c#answered Leonel Sanches da Silva 88,623 -
5
votes1
answer1342
viewsA: How to convert date to datetime?
Use the command ISDATE to verify what cannot be converted: SELECT * FROM tb_RHContratos WHERE isdate(DtCadastro) = 0 The tip I was going to give was to use datetime2, that supports very old dates,…
-
1
votes2
answers94
viewsA: How to obtain data entered in a form not yet recorded?
The didactic way to do this is to create two Actions in the Controller, where one only passes the data to the confirmation screen and the other effectively carries out the database changes:…
-
1
votes2
answers325
viewsA: Interpret replies from responsive card
The best way to do it is to go after an OCR library (Optical Character Recognition). Here’s a great article about this. There is also the Tesseract, OCR mechanism that is not native to . NET, but…
-
2
votes1
answer479
viewsA: Open external program via mvc5
Basically, what you do is the same as the Rotating do, then I’ll play the method invoking the service with some changes to your case, reads its output and converts it into an array of bytes, which…
-
4
votes1
answer59
viewsA: Is the query generated by the Entity Framework valid for use in ADO?
The query it generates when performing the query, could be used to create a precedent or use with ADO? Yes. The problem is that it is in a much more convenient format for manipulation by the Entity…
-
1
votes1
answer1369
viewsA: From the View how to get the Model in Partial View
I still don’t understand why, but the correct way to send is to transform the content of Partial in fields of form. It may be by <input type="hidden">: @foreach (var item in Model) {…
-
0
votes2
answers372
viewsA: Collate Mongodb
Has a query operator called $text. An example of how to do: var comandoPesquisa = new CommandDocument { { "text", typeof(UnidadeCurricular).Name }, { "search", nome } }; var commandResult =…
-
0
votes1
answer70
viewsA: String nonce is not being generated
To work, payment_method_nonce needs to be created as a field <input>. May type=hidden. In your case, the field is not being created this way. A suggestion would be you create the empty field…
-
2
votes1
answer923
viewsA: Tips to improve the performance of an ASP.NET MVC site
Despite being a broad theme, I wanted to know if you have some tips or a starting point to guide me on how to improve application performance. There are several. I will try to be succinct in the…
-
2
votes1
answer523
viewsA: I’m not getting a Oracle file with Code First
This is the terribly difficult way to work with the Oracle driver within ASP.NET MVC. The easy way is installing the official Nuget package from Oracle. There are two ways to do: In Visual Studio,…
-
2
votes1
answer146
viewsA: How to format money with jade in Node.js?
There are several packages on npm that can serve what you need: Numeral Accounting Format As Currency Jade itself does not have a special structure for conversion into monetary format. Example: //…
-
0
votes2
answers1182
viewsA: How to remove mask from the field before calling the controller with Asp net MVC
The way I found to solve it is based on a field string unmapped in Model and another decimal, this yes mapped: [Required] public Decimal Cnpj { get; set; } [NotMapped] [Cnpj] public String…
-
4
votes1
answer67
viewsA: How to separate a fixed route from a variable route with Asp.net mvc5
Try reversing the methods: [Route("video/categoria/new-movies")] public async Task<ActionResult> Index() { } [Route("video/categoria/{categoria}")] public async Task<ActionResult>…
-
1
votes1
answer96
viewsA: Asp net mvc 5 resize image
Yes. Utilize the Nuget Imageresizer package. Example: [HttpPost] public ActionResult Create(MeuModel meuModel) { if (meuModel.TypeImageFile1 != null && meuModel.TypeImageFile1.ContentLength…
asp.net-mvc-5answered Leonel Sanches da Silva 88,623 -
7
votes1
answer7623
viewsA: Get only first word within a sql server query
It’s not much of a secret: SELECT COUNT (SolID) as quant, SUBSTRING(UsuNome, 1, CHARINDEX(' ', UsuNome, 1) - 1) as gerador FROM Solicitacao INNER JOIN Usuario ON Solicitacao.UsuIDAtendenteViaFone =…
-
4
votes1
answer613
viewsA: How to create a symbolic link to a Python code on Linux?
It’s the same: ln -s /home/usuario/codigo.py /usb/bin/script
-
6
votes1
answer294
viewsA: Is it possible to make a condition within a Select?
Yeah, but not with the parole inside Select: var entity = context.Clientes .AsNoTracking() .ToList(); if(viewModel.CarregarNome) { var retorno = entity.Select(x => new { x.Nome }); } else { var…
-
0
votes1
answer73
viewsA: Viewmodel parameter being passed as null
The problem is in the constructor, where you put a behavior that, in addition to not being necessary, disturbs the validator. public EfetuarLoginViewModel() { Login = String.Empty; Senha =…
-
8
votes1
answer6777
viewsA: How to run another program by python?
Yes. Define your file engine.py more or less as follows: def calcular_equacao(a, b, c): delta = (b * b) - 4 * a * c print("Delta:", delta) if delta<0: print('Essa equacao nao tem raiz real')…
pythonanswered Leonel Sanches da Silva 88,623 -
4
votes1
answer346
viewsA: Billet generation
The Path of Stones Here is an example project. Just download the zip or clone the repository and test. It’s not very secret. To install in your project, use the Nuget package. Here’s a step-by-step…
-
2
votes1
answer64
viewsA: SQL Server 2012, error executing query
PED_Numero is a column that exists in pedido and in item. To undo ambiguity, define table identifiers for the columns and for the tables involved: select pr.PRO_Descricao, p.PED_Numero from pedido…
-
4
votes1
answer203
viewsA: Choose which items of a enumerator appear in an Enumdropdownlistfor
For this case I do not find it productive to use EnumDropDownListFor. I think I’d better use the DropDownListFor and define all the logic within: @Html.DropDownListFor(model => model.Documento,…
-
2
votes2
answers459
viewsA: Send parameters to a C#interface
You need to define all interface items in the class, as enunciates the architecture by C contracts#: class descricaoo: IInstrucao { private string descricaobol; public descricaoo (int ibanco, int…
-
9
votes2
answers102
viewsA: What’s this code for?
This is the declaration of an empty object: var PROD = {}; The rest are also, but as properties of this object as new objects. About the code: PROD.clients = { init: function(){}, method1:…
javascriptanswered Leonel Sanches da Silva 88,623 -
1
votes1
answer52
viewsA: How to avoid controller duplication/accountability in modern applications?
In the case of ASP.NET MVC5, where it is impossible to do the same Controller serve more than one type of information format, the most appropriate approach is to write an intermediate layer that…
-
5
votes1
answer190
viewsA: Difference between "list(range(1, 10))" and "range(1, 10)"?
Not. range is a class which can be initialized with three arguments: start, end and increment. Therefore, it does not equal a list. It can generate a list if converted to list because it has the…
-
5
votes2
answers1685
viewsA: How to format all elements of a list in Python?
Yes. numeros = list(range(1, 10)) resultado = [str(x).zfill(4) for x in numeros]
-
5
votes1
answer2341
viewsA: How to pass a Controller object or object list to View?
This is yet another question that shows the nonsense (and futility) of implementing repository with Entity Framework (which is already a repository). I explain everything here, but as you’re…
-
2
votes1
answer65
viewsA: How to put a form in the _Layout view?
Partials can’t stand it @section Scripts. The correct thing would be for this code to stay in _Layout or any View, but it would have to be modified. Don’t leave it on Partial. My suggestion to…
-
6
votes1
answer900
viewsA: More elegant ways to invert integers, arrays and strings in Python
About this form: frase = 'eu gosto de python'[::-1] Not only is it the most performative but also the fastest for all cases. This is also true for this form: numero = [12, 13, 14, 15, 16, 17][::-1]…
-
0
votes1
answer106
viewsA: Ensure that Httpconfiguration.Ensureinitialized()
The most important file is missing: Global.asax.cs. Anyway, this is a classic Web API error. In Web API 2, the global configuration record has changed shape. In the file Global.asax.cs root…
-
4
votes3
answers337
viewsA: Recover MAX value from an SQL column
For your case do not need to search by index String: if (dr.Read()) var = (((IDataRecord)dr)[0]).ToString();
-
9
votes1
answer188
viewsA: How to use Ivalidatableobject?
IValidatableObject asks to implement Validate, which is a method that takes as an argument a ValidationContext. public IEnumerable<ValidationResult> Validate(ValidationContext…
-
5
votes1
answer108
viewsA: Required validating property of another object
Don’t use this: [Required(ErrorMessage = "Grupo deve ser selecionado")] public GrupoDeUsuario GrupoDeUsuario { get; set; } Navigation properties are complex entities. You should only keep this…
-
3
votes1
answer851
viewsA: How to get the path of a file (Httppostedfilebase)?
Assuming a Action of Controller, you can get the file as follows: private const String DiretorioCurriculos = "~/Curriculos/"; [HttpPost] [ValidateAntiForgeryToken] public async…
-
9
votes4
answers2691
viewsA: Reports with Asp.Net MVC
Yes. Some. Razorpdf2; Mvcreportviewer; Rotating; ASP.NET MVC Reports (Devexpress).…