Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
3
votes1
answer43
viewsA: Register Assembly on Asp.net MVC?
There’s a package for that, the Reportviewer by MVC. You can easily install it into your ASP.NET MVC solution using the following command in the Package Manager Console (View > Other Windows >…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
4
votes1
answer38
viewsA: Taking all files with the name started by something in a directory
It’s not much of a secret: Directory.GetFiles("C:\\diretorio", "javaw*", SearchOption.AllDirectories); For recursive search, and Directory.GetFiles("C:\\diretorio", "javaw*",…
c#answered Leonel Sanches da Silva 88,623 -
0
votes2
answers149
viewsA: How to resolve error with OWIN?
Check if there is a Startup Class in your project; Check whether the Startup Class has the following annotation before the class declaration: [assembly:…
-
4
votes1
answer311
viewsA: LINQ Group By with multiple fields in key
It’s not much of a secret: foreach (var grupo in lst) { Console.WriteLine("Categoria: {0}, Id da Categoria: {1}, Itens: {2}", grupo.Key.Categoria, grupo.Key.IdCategoria, grupo.Count()); ... Rather,…
-
2
votes2
answers254
viewsA: Scaffold MVC Template Editing. How to get project reference in Solution Folder?
Just continue reading the other levels to locate the user classes you want to locate. The following code may be useful: var proj = env.Solution.Projects.OfType<Project>() .Where(p => p.Name…
-
1
votes1
answer188
viewsA: Log in to AD
I have a Helper which can be useful for your case. As it is static class, it can be implemented in any solution and improved. Note that there are several ways to do a certain search. Some use…
-
5
votes2
answers548
viewsA: Memory error when entering millions of records using Entity Framework
In this answer, I explain several alternatives you can use to improve performance, but I do not believe that, even used together, they will solve your problem completely. There are some things that…
-
1
votes1
answer159
viewsA: Linq function does not return List
It’s almost all right. Some adjustments are required. Remove this: public Fornecedor() { this.Entrada = new HashSet<Entrada>(); this.Produto = new HashSet<Produto>(); } Browsing…
-
2
votes2
answers589
viewsA: Read the last 5 lines of a file through Python
The most elegant solution I found (among the many that exist) is this: def tail(f, n): assert n >= 0 pos, lines = n+1, [] while len(lines) <= n: try: f.seek(-pos, 2) except IOError: f.seek(0)…
-
4
votes2
answers2085
viewsA: LINQ Group By with multiple fields
This returns List<n'>, in which n' is an anonymous guy: var lst = from p in Produto.produtos join c in Produto.categorias on p.IdCategoria equals c.IdCategoria group p by new { c.IdCategoria,…
-
5
votes2
answers3368
viewsA: Send email using ASP.NET MVC
Yes. For example, the Sendgrid. I set up a Helper for him like this: public static class SendGridHelper { public static async Task EnviarEmail(String assunto, String mensagemHtml, String…
-
5
votes4
answers5763
viewsA: Capture Real User IP
This is a variable accessible in any Action: Request.UserHostAddress; Or else: Request.ServerVariables["REMOTE_ADDR"]…
asp.net-mvc asp.net asp.net-mvc-5 asp.net-mvc-4 asp.net-identityanswered Leonel Sanches da Silva 88,623 -
4
votes1
answer220
viewsA: Why does Python allow you to overwrite the value of False and True?
Why in Python is it possible to do this? Because they are not reserved words, like in PHP or other languages. Are scoped variables with defined values (the documentation puts the word "Constant",…
pythonanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer82
viewsA: Destroy tag javascript
No. Everything indicates that your code is full of bad practices. First of all, a Partial should not have Javascript code inside it. The code should be all in the View Father, just to avoid this…
-
5
votes1
answer156
viewsA: Regular Expression, picking numbers between two predefined texts
Regular expression is correct. Only the desired result needs to be grouped and selected: var re = new Regex(@"/(\d+)(?=-)"); var match = re.Match("http://www.meudominio.com/1789519-texto");…
-
2
votes1
answer2873
viewsA: How to set today’s date as default value in a texbox as date input type?
From what I understand, you’re wearing a DateTimePicker. At the event Page_Load, I believe it is only necessary to define the field with the current date. txtData.Value = DateTime.Today; EDIT In the…
-
1
votes1
answer46
viewsA: What are the most common ways to enter data remotely?
WCF It is the service-oriented architecture of Microsoft. You can start with this tutorial if you want to learn now. WCF can work, in theory, with any data model, such as XML (default), JSON, Odata,…
.netanswered Leonel Sanches da Silva 88,623 -
0
votes1
answer99
viewsA: nhibernate save string in upper case (uppercase)
Yes, defining a UserType customized: public class UpperString : IUserType { public UpperString() { } #region IUserType Members public new bool Equals(object x, object y) { bool returnvalue = false;…
-
1
votes1
answer1072
viewsA: Application pool hangs and no back application
Use Response.Redirect is a bad deal on ASP.NET MVC. The chance of you causing collision of request headers is quite large. Avoid using: Response.Redirect("/ControllerQualquer", true); Switch to:…
-
2
votes1
answer521
viewsA: Get child tag reference from XML C#
This is, in my view, the worst way to read an XML. Use Xdocument in place: XDocument document = XDocument.Load("clientes.xml"); var clientes = document.Root.Elements("cliente").ToList(); var…
-
3
votes1
answer97
viewsA: Entity Framework Extra column when using Icollection
I don’t agree with that nomenclature of tabela even because the Entity Framework is agnostic about the database, so it doesn’t necessarily operate in the relational model, just on top of tables. It…
-
3
votes1
answer466
viewsA: Mapping of Associative tables with Entity Framework
This is wrong here: public class DiaSemana { public DiaSemana() { Tarefas = new List<Tarefa>(); Clientes = new List<Cliente>(); } ... public virtual ICollection<Tarefa> Tarefas {…
-
3
votes1
answer672
viewsA: Dbupdateexception exception
For this mistake: An unhandled Exception of type 'System.Invalidoperationexception' occurred in Entityframework.dll Additional information: The model backing the 'Schoolcontext' context has changed…
-
13
votes2
answers636
viewsA: Why does linux have an ISO for each processor architecture?
I would like to understand why Linux has several ISO’s for each CPU type (amd64, i386, etc.) and why Windows does not need this? Because the processor architecture influences the entire compilation…
-
2
votes1
answer1201
viewsA: Error after configuring Authorization on Web.config
Your setup is wrong. This doesn’t even work: <allow users="maquinaLocal\usuario"/> The configuration below: <authentication mode="Windows" /> <authorization> <deny users="?"…
-
8
votes2
answers339
viewsA: Where to put Data Annotation? View Model or Model?
Not Viewmodels do not serve to create entities in a bank. [MaxLength] serves precisely to specify the width of the column in bench. Therefore, [MaxLength] should be used only in Model. To…
-
3
votes3
answers185
viewsA: Update to 2 tables
The approach is incorrect. This error you are experiencing: "Store update, Insert, or delete statement affected an Unexpected number of Rows (0). Entities may have been modified or Deleted Since…
-
2
votes1
answer372
viewsA: How to create connector for active Diretory?
I don’t know where you got that Migrations is related to Active Directory. Anyway, I am constantly updating a Helper which I made for Active Directory, and which can be used by any application…
-
1
votes3
answers472
viewsA: MER - Temporal confusion of cardinality
I think the confusion starts in this analysis: [PROFESSOR]1------<LECIONA>------N[ALUNO] In associations 1 to N, there is no associative table between them. You could express the relation as…
-
1
votes1
answer36
viewsA: Populating a field by selecting a dropdowlist via popup
The simplest way is using jQuery. The jQuery can be obtained here. To open a pop-up, you can intercept the pop-up change event and call the window. <script> $('#meupopup').change(function(e) {…
-
2
votes1
answer1646
viewsA: E-commerce with ASP.NET MVC
Does anyone know if there is any course, guide or material that contains what I need to build an Ecommerce with ASP.NET MVC? This course teaches some steps to create a virtual store in ASP.NET MVC.…
-
17
votes2
answers14331
viewsA: How does Groupby work on LINQ?
GroupBy serves to group elements according to a certain value in common between them. For example: public class Fruta { public String Cor { get; set; } public String Nome { get; set; } } Suppose…
-
1
votes1
answer116
viewsA: 'System.Stackoverflowexception' When running Migration with Dbmigrator
The problem is this initializer: static DbContext() { Database.SetInitializer<AppDbContext>(new CustomAndMigrationDatabase<DbContext, Configuration>()); } When creating a new context…
-
2
votes2
answers829
viewsA: Asp.Net MVC Validators passing through the controller
I created a form with the following in Razor: <div class="form-group"> @Html.LabelFor(model => model.DataNascimento, htmlAttributes: new { @class = "control-label col-md-2" }) <div…
-
1
votes2
answers1026
viewsA: How to resolve "Typeerror: must be Unicode, not str" error in Python?
In Python, str would be a binary type of data, while unicode is something more elaborate. You opened the file hoping to receive unicode and is trying to write str, therefore the mistake. There are…
-
8
votes2
answers2381
viewsA: Router and URL-friendly with Asp.net mvc
This question already has an answer, but I couldn’t schedule to close, so I’ll reply again. This description that stands after the address is called Slug. In this case, what you need to do is a…
-
5
votes4
answers2257
viewsA: Check if user is logged in
Just complementing @Richarddias' reply, setting the Web.config varies from technology to technology. ASP.NET Identity <configuration> ... <system.webServer> <modules> <remove…
-
2
votes1
answer416
viewsA: Injection of MVC dependency
I do not see how it is necessary to create an interface for both. In this example, the Mocking is carried out over a layer of services and injected using Ninject. In this other, from the ASP.NET MVC…
-
14
votes3
answers1166
viewsA: Write Timespan in full
Just out of curiosity, I implemented the @Maniero response as a Extension, next: public static class RelativeTimeExtensions { public static String PorExtenso(this TimeSpan timeSpan) { const int…
-
18
votes3
answers1166
viewsQ: Write Timespan in full
I want to write a static class (can be Extension) to represent the value of a structure TimeSpan in full, in Portuguese. The idea is to always compare the current date (Datetime.Now) with the date…
-
1
votes1
answer49
viewsA: No automatic component alignments in Visual Studio
Go on Tools > Options... > Windows Forms Designer; Check that checked options are checked:…
-
1
votes1
answer195
viewsA: Select two attributes from two different tables in a view
Your modeling is incorrect. A Aluno is a Pessoa, therefore Aluno must be a derivation of Pessoa: public partial class Pessoa { // Isto está incorreto, então comentei. // Quem inicializa propriedades…
-
1
votes4
answers754
viewsA: String Array Printing in a Single Messagebox
You can carry out this printing using the function Aggregate. For example: MessageBox.Show(dataTransacao.Aggregate( (acumulador, posicao) => acumulador + ", " + posicao, "Título"),…
-
3
votes3
answers31605
viewsA: Check if the element exists in Arraylist and, if not, add it
The simplest way would be using Contains(): if (estados.contains(e)) { System.out.println("Esse estado já foi adicionado ao país anteriormente."); } else { estados.add(e); System.out.println("Estado…
javaanswered Leonel Sanches da Silva 88,623 -
4
votes3
answers145
viewsA: DER Student Question Theme
If I were you, I’d put the answer in the association Pergunta_Atividade: +----------------------------------------------------+ | Pergunta_Atividade |…
-
2
votes1
answer571
viewsA: Asp.NET MVC checkbox list bind with string value
It’s a classic case of Begincollectionitem. Do the following: <div class="editor-field perfil-filtro-expander-todasAcoes"> <div class="metro perfil-filtro-expander-overflow todasAcoes"…
-
2
votes1
answer97
viewsA: Use viewbags for metadata or place them in a Viewmodel
This instruction order here is not good: [HttpPost] public ActionResult Cadastrar(CadastrarUsuarioViewModel model) { ViewBag.Estados =[...]; //List de selectListItem ViewBag.Cidades = [...];…
-
4
votes3
answers2559
viewsA: Is it possible to add int with str composed of text and numbers in Python?
It would be possible to make expressions of the type 1 + int('1 cachorro') work in python? Not. Or you sum whole or concatenate strings. This is part of Python type security. If I needed to do this…
-
2
votes1
answer1058
viewsA: How do I add more than two conditions to an Expression dynamically?
Expression trees are valid ways to build a predicate for use with the Entity Framework, but in this case I think you are complicating. Where returns IQueryable. The object that implements IQueryable…
-
2
votes1
answer31
viewsA: Urlrewrite for photo name - Web
Step 1: Configuring the Request Engine First, you need to inform your application that it will treat file-terminated requests differently. To do this, modify your file web.config, adding the…