Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
4
votes1
answer170
viewsA: How do you fix columns on a Listview?
Being a DataGridView, you can set the property Frozen as true: this.livCamposForm.Columns["lblCodigo"].Frozen = true; With ListView I believe it is not possible to do this. The definition of columns…
-
5
votes3
answers1283
viewsA: Remove Saturdays and Sundays from Calculation
There is a the Fluentdatetime Nuget package who does it with great elegance: atividade.Inicio = status.InicioPrevisto.Value; atividade.Duracao = 7; atividade.Termino =…
-
13
votes1
answer3723
viewsA: Methods Executereader(), Executenonquery() and Executescalar(), what are the differences and how to use them?
Executereader Used to perform a field-to-field reading on top of a data extraction. This is done through the type object SqlDataReader returned by the method. Example: using (var connection = new…
-
3
votes1
answer60
viewsA: If there is update a table and insert into another, if not, insert into the two
It already exists. It’s the extension AddOrUpdate. Use: ctx.Entidade.AddOrUpdate(e => e.Id, objetos); The first field is the field that the Entity Framework will do to verify whether or not the…
-
4
votes1
answer117
viewsA: Accessing data stored in cookies?
You use the old way, which was used in Web Forms. It can be done this way: HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; FormsAuthenticationTicket ticket =…
-
14
votes2
answers2001
viewsA: Documentation in software development
What would be a good way to document the software? It depends on several things, but I would say that initially it would be following the design pattern that the community that developed the pattern…
-
3
votes1
answer311
viewsA: :before does not work as it should
Font Awesome is installed wrong. As is ASP.NET MVC, use the appropriate Nuget package to use it. Also check your file App_Start/BundleConfig.cs there is a CSS entry for Font Awesome CSS. I use it…
-
2
votes2
answers306
viewsA: <httpErrors> does not work
Yes. Some. The correct configuration initially would be like this: <configuration> ... <system.web> ... <customErrors mode="On"> <error statusCode="404"…
-
4
votes1
answer1726
viewsA: How to pass parameter via button
Make sure your form is using the method GET: @using (Html.BeginForm("Pesquisa", "Cliente", FormMethod.GET)) { <div> <button id="BtnConsulta" name="parametro" value="valor" type="submit">…
-
0
votes2
answers15582
viewsA: Why does the background-image url search for the image inside the Content folder?
In your case, this solves: #hero { height: 100%; background-image: url("/Content/img/bg-img.jpg"); background-position: top center; padding: 0; overflow: hidden; } CSS does not interpret ~.…
-
3
votes1
answer271
viewsA: Web service security attributes
For Web Services, the correct is define an HTTP module that handles SOAP headers. Next, we need to define a web method that does this header handling, then yes using the already known attributes. A…
-
4
votes1
answer83
viewsA: Security Attributes
For both ASP.NET MVC and Web API, we are talking about AuthorizeAttribute. The questions I’ve already answered are here. Basically this is what he does: by entering a Controller or Action that has…
-
9
votes4
answers542
viewsA: Why use block using in ASP.NET MVC?
The block using {} works in the same way in both web applications and desktops in the sense of when we use it in controller? Yes. About the examples This one is good when you own several Actions in…
-
2
votes1
answer1754
viewsA: How to translate Summary errors Asp . net validation error messages?
There’s a Nuget package that does that. The details are here. Or you can reimplementate the PasswordValidator of ASP.NET Identity. EDIT ASP.NET Identity has its own package of Resources to the…
-
15
votes4
answers3299
viewsA: Typing the return in PHP 7. What are the advantages?
What are the advantages of using the definition of return type (return typing)? The same as any language with type discipline: security and cohesion and data. In dynamic typed languages, depending…
-
2
votes1
answer781
viewsA: Undefined Object Reference for an object instance when trying to retrieve an element in an XML file
This can be simplified to: x = xml.Elements().FirstOrDefault(p => !p.Attribute("novoLote").Value.Equals("")); Still, it is prone to errors. You can improve the sentence to: x =…
-
5
votes2
answers1410
viewsA: Remove all records from a table with Entity framework 6
The simplest way is: context.Database.ExecuteSqlCommand("TRUNCATE TABLE [Tabela]"); Yes, this does not go directly through the Entity Framework. To explicitly use the Entity Framework, it is best to…
-
2
votes2
answers734
viewsA: Error passing values to @Html.Dropdownlist
@Html.DropDownList can’t guess what’s in your ViewBag. You have to report this to her in code. For your case, the following construction is the most recommended: @Html.DropDownListFor(model =>…
-
6
votes1
answer937
viewsA: Entity Framework attribute list for entity mapping
Most of the attributes are here and here, but I will make a quick guide that can be useful for your conversion. Field attributes (properties) [Key] Specifies when a property is or is part of a key.…
-
7
votes1
answer104
viewsA: Problem with . Include() in Entity Framework(Postgres)
The elegant way to solve it is by forcing the attribute [ForeignKey] in the Model: [Table("usuarios", Schema = "public")] public partial class Usuario { [Key] public Guid id { get; set; } public…
-
2
votes1
answer1007
viewsA: How to implement PKCS#7 (components->class, library, dll, plugins and others) in a MVC5 web application
I once made an application that receives digital certificates of type X509 (which implement PKCS#7) and I can put some suggestion codes here. Some of them are mine and some I tidied up online some…
-
3
votes2
answers182
viewsA: Local database (serveless) not modifiable with update
Just leaving my 2 cents, there is portable SQL Server mode called Localdb. You do not need to install the entire SQL Server on the user’s machine: only the client adapter and the MDF file…
-
3
votes1
answer686
viewsA: Program that opens Notepad in the background
The following code opens the Notepad and inserts a text inside: [DllImport("user32.dll")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string…
-
9
votes1
answer2938
viewsA: How to convert a string to Base64 in Python?
It’s like that. You just have to make one import: >>> import base64 >>> encoded = base64.b64encode(b'stack overflow') b'c3RhY2sgb3ZlcmZsb3c=' b64encode asks for an array of bytes,…
pythonanswered Leonel Sanches da Silva 88,623 -
2
votes2
answers3604
viewsA: Specified conversion is not valid
The mistake you’re having is not in the Count. Is here: var query = PessoasVinculadas .AsEnumerable() .Where(x => x.Field<int>("tipo") == TipoVinculo &&…
-
9
votes2
answers15191
viewsA: How do I know if a list is empty in Python?
I suppose a a list: a = [] Test yourself like this: if not a: # Condição se for vazio. Yes. Very simple.
-
20
votes4
answers3838
viewsA: What is the expression 'if __name__ == "__main__"' for?
if __name__ == "__main__" tests whether the Python script file is running as the main file or not. This is useful to avoid certain behaviors if your script is imported as a module from another…
pythonanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer99
viewsA: XML for temporary table records
I think it doesn’t change much. The difference is that you won’t put the value in the variable, and you’ll need to make a cast in the column as follows: DECLARE @DataIni DATETIME = '2015-09-07…
-
2
votes2
answers157
viewsA: What’s position on Sqlserver?
Well, the question does not seem to be specifically about SQL Server. It seems to be about import and export layouts. I will answer and then we will see the tags appropriate to pose the question. A…
-
2
votes1
answer189
viewsA: How can I make a MVC lambda filter
Better you target this search by testing what is filled: var query = db.Forecast; if (idArea != null) { query = query.Where(f => f.CanalForecast.area == idArea); } if (idDespesa != null) { query…
-
4
votes1
answer330
viewsA: How to filter a List<Dictionary<string, Object>?
You can simplify it a lot more: var listaMatrizFiltrada = listaMatriz .Where(item => item["COD_OCUPACAO"] == 1 && item["COD_NIVEL"] == 1) .ToList(); Like ListaMatriz is a list of…
c#answered Leonel Sanches da Silva 88,623 -
3
votes2
answers1798
viewsA: Show current date in Editorfor Razor
@Html.EditorFor is a component that binds to an item in your Model (or Viewmodel, if applicable). Therefore, if your class has such a field: public DateTime MeuCampoData { get; set; } You just have…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer291
viewsA: How to pass ID via Javascript to a View
I wouldn’t even need to use Javascript. A normal link already solves everything. onclick="location.href='@Url.Action("Cadastro", "Cliente", new { id })'"
-
1
votes1
answer5098
viewsA: Select nested Mysql
There are some problems in your sentence. First I will put as it is corrected, then I will explain: SELECT district FROM (SELECT district, min_postal_code from (SELECT district, MIN(postal_code) as…
-
1
votes1
answer133
viewsA: Procedure pl/sql
You used BEGIN twice when defining a procedure: create or replace procedure pr_voxis_beneficiario( p_retorno_beneficiario out varchar2, p_retorno_pessoa out varchar2) is begin -- aqui merge into…
-
9
votes1
answer591
viewsA: Change the naming pattern of views that are generated by scaffold
For this answer, I suppose you’re using the package Mvcscaffolding.VS2015 in the latest version. If you have any problems with the latest version, use version 1.0.10, which works only for VS2015.…
-
1
votes2
answers322
viewsA: Read document array of word bytes in browser
Without using external components (such as Aspose.Words, which is paid), can be done as follows, using Word interoperability objects: private Microsoft.Office.Interop.Word.ApplicationClass MSdoc;…
c#answered Leonel Sanches da Silva 88,623 -
2
votes1
answer76
viewsA: Use Pattern View Model or a POST method with Json?
Viewmodels I’ve given a lot of answers about that, but I didn’t mention the advantages of them, so I’m going to talk about some. 1. Variable Exposure Control The approach is often used when it is…
-
2
votes4
answers595
viewsA: How to create a variable where to access its properties via string?
Just convert the object to dictionary. This answer has the method below that can serve well: public static KeyValuePair<object, object> Cast<K, V>(this KeyValuePair<K, V> kvp) {…
-
1
votes1
answer1724
viewsA: I have the reference, but when I run the CLR says the reference is missing
Its configuration is quite wrong. An ASP.NET MVC application has two files Web.config, being one inside the directory Views and one in the root directory. What you did was mix the two. This needs to…
-
2
votes1
answer691
viewsA: Bundleconfig does not load all CSS files
There is a small spelling error in your setup. Note that your Bundle is like: bundles.Add(new StyleBundle("~/Content/themes/base/css").Include( "~/Content/themes/base/jquery.ui.css",…
-
1
votes4
answers492
viewsA: Orable DB and MVC 4 - Connection error (ORA-06413)
Adding the DLL directly can be a problem, especially considering that there may be a change of environments when publishing your application. Instead of adding the DLL directly, use the official…
-
2
votes2
answers394
viewsA: blocked by software Restriction policies?
In the Package Manager Console, type the following: PM> Set-ExecutionPolicy Unrestricted There are no problems in reducing the script constraint policy on a development machine. If it doesn’t…
-
0
votes1
answer265
viewsA: How to pass a post with an array to a Webform URL
Apparently everything is right. All that remains is to collect the answer: private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HttpWebRequest request…
-
2
votes1
answer1604
viewsA: See Date only, in a Datetime field with LINQ
Your approach is correct, using DbFunctions.TruncateTime, but I believe you may not pass the conversion into the Linq sentence, solving the variables before, as follows: if…
-
3
votes3
answers3309
viewsA: Generate PDF with Asp.Net MVC
Razorpdf is a good alternative, but it is incompatible with iTextSharp version 5 or higher. Thinking about it, I developed Razorpdf2. Here are some examples of use. Basically, define your View…
-
4
votes3
answers9903
viewsA: Get the last N characters from a string
I like the regular expression approach. var regex = new Regex(@"([\d]{8})"); var match = regex.Match("+55 34 98989898"); if (match.Success) { Console.WriteLine(match.Value); // Imprime "98989898" }…
c#answered Leonel Sanches da Silva 88,623 -
1
votes1
answer114
viewsA: XML for Database Columns
For testing purposes, place your XML inside a variable to test. Note that I edited the namespaces to work: declare @data xml = '<Viagem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">…
-
2
votes1
answer135
viewsA: Problem with Viewbag and Viewdata for Breadcrumb Creation
The question and answers already exist here, but I find it interesting to put another example of breadcrumb, whereas I have left the simplest approach in recent times. The information for mounting a…
-
3
votes1
answer89
viewsA: How do I extract values from an Expression?
As I told you in the previous question, there are various types of Expressions, which requires you to put additional logic to recover your filter values. Normally, this parameter Expression is a…