Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
- 
		3 votes2 answers234 viewsA: Adding Text Box and Writing to Database. (with C#, entityframework 6.1.3)Well, it’s all right for you to use the Begincollectionitem. Just implement now. My suggestion for the installments starts in the code of View down below: <div class="condicoes-pagamento"… 
- 
		4 votes2 answers1697 viewsA: Control view component visibility in the ASP.NET MVC 5 controllerUsing session variables in this way is quite dangerous: @if ((bool)Session["TipoChamadoVisivel"]) { ... } Because you don’t test the existence of this content before using it. Also, this way of… 
- 
		1 votes1 answer215 viewsA: C# set a condition for a column value in a Datagridview with DatasourceIf you talked about CalcFields, apparently you came from Delphi. In Webforms, things are not so different. What changes is the event you will use to display the values. In this case, the correct… 
- 
		3 votes1 answer2708 viewsA: How to configure ASP.NET MVC validation to accept en-BR dates?Failed to add the jQuery.Validation.Globalize and make reference to it in the BundleConfig. This will possibly bring an extra problem: Yours DateTime will appear as YYYY-MM-DD. This is because the… asp.net-mvc datetime jquery-validate annotation globalizationanswered Leonel Sanches da Silva 88,623
- 
		2 votes2 answers1871 viewsA: Append methods in a list - PythonIts function does not print anything. So it does not return anything in print. I made some corrections: def setVar(number): var = number return var methodList = list() for y in range(4):… pythonanswered Leonel Sanches da Silva 88,623
- 
		2 votes1 answer77 viewsA: Which components should I use for color and photo selection in ASP.NET?For colors there are two: the Jscolor and the Bootstrap Color Picker. To thumbnails you can use the Imageresizer. For display of thumbnails, you can use, combined with Imageresizer, the Owlcarousel.… 
- 
		2 votes1 answer148 viewsA: Controller dependency injection with AjaxFor this tutorial here, I think there are some things missing. It should be working, but apparently ASP.NET MVC gets lost somewhere at build time Controllers to the Ajax. Global.asax.Cs protected… 
- 
		5 votes3 answers633 viewsA: Loop variable declaration errorPut the whole declaration out of the loop: int i; for(i = 1 ; i <= 3 ; i++) { ... } Possibly this compiler version is quite old, or is defined for version C89. Another solution you can try to do… 
- 
		2 votes3 answers100 viewsA: Will I lose my databases if I update SQL Server 2012 Express to Standard?Not. This link teaches you how to do the installation steps. In any case, I recommend a backup of schema + dice. There’s a step-by-step for that here.… 
- 
		3 votes1 answer1210 viewsA: Query using the Entity frameworkIt would be something like that: public tb_empresa ListarPorId(string id) { int idInt; Int32.TryParse(id, out idInt); var Consulta = contexto.Empresa.First(x => x.IDEMPRESA == idInt &&… 
- 
		1 votes2 answers447 viewsA: How to adapt / create a method that receives an anonymous class in C#If the goal is to provide a dynamic mapper for C#, there are already some ready, like the Automapper. If the goal is to implement to learn, I can say that I have never seen this construction of… 
- 
		2 votes3 answers2406 viewsA: Access content from another project in the same SolutionThe correct approach would be to create, on the administrative site, a suitable interface to serve the images. To do this, create a Controller called ImagensController. Inside it implement the… 
- 
		6 votes1 answer773 viewsA: Write include date using Entity frameworkThe correct way is to put the date update on SaveChanges of context: public override int SaveChanges() { var context = ((IObjectContextAdapter)this).ObjectContext;… 
- 
		2 votes1 answer208 viewsA: Doubt in the operation of Automatic Migration with MigratedatabasetolatestversionWith automatic Migration the database is updated also when there is deletion of some property from my model class? That is, in addition to including a new attribute if something is added to my… 
- 
		5 votes2 answers213 viewsA: Value priority data ordering using LINQIt would be something like that: var lista = contexto.Entidade .Where(/* Sua condição aqui */) .OrderBy(e => e.Status == 2) .ThenBy(e => e.Status) .ToList();… 
- 
		11 votes2 answers204 viewsA: What is the name of the ... operator used in PHP 5.6?Splat (or, Scatter, or Spread). It is an operator to indicate that its function can have any number of parameters. This name is specific to PHP. In other languages, the name changes. If your… 
- 
		10 votes5 answers2497 viewsA: What is the purpose of the "Spaceship Operator" <=> of PHP7?The documentation already says well what it is: The operator Spaceship is used to compare two expressions. It returns an integer less than, equal to, or greater than zero when $a is respectively… 
- 
		3 votes1 answer103 viewsA: Self invoking functions in PHP 7. What are the advantages?The resource goes in the direction of what we call, in other languages, delegate functions. There’s even a proposal for PHP 7 where the concept is even better developed. The advantage of this type… 
- 
		2 votes1 answer1689 viewsA: Error while running ReportviewerWell, the mistake is quite clear and tells you exactly what to do. Basically, it’s putting the following in your web.config: <configuration> ... <system.web> ... <httpHandlers>… 
- 
		3 votes1 answer54 viewsA: Error adding migration with MigrationsAll right. This message means: The code in mode designer for this migration includes a Snapshop (photo) of your model on Code First (the set of Models here, in the case). This photograph is used to… entity-framework-6answered Leonel Sanches da Silva 88,623
- 
		0 votes1 answer142 viewsA: Controller search structure mvc 5Not. Visual Studio supposes all its Controllers are in the default project structure, that is, just below the directory Controllers. There is no way to change this behavior, because Views do not… 
- 
		1 votes1 answer164 viewsA: problem with jQuery ajaxThis is not how you mount a JSON to send the request: var jsonData = $.ajax({ type: 'POST', dataType: 'json', contentType: 'application/json', url: url, data: "{ top: " + top + ", dataInicio: '" +… 
- 
		1 votes4 answers490 viewsA: Start connection to SignalrI didn’t have to do any of that. An example: <script type="text/javascript"> $(function () { // Inicializo a conexão. var realtimeNotifier = $.connection.realtimeNotifierHub; // Trato as… 
- 
		6 votes2 answers1043 viewsA: ASP.NET Identity and mapping Many to Many (Fluent API)First of all, I would like to say that I needed to study this solution during the interval weeks in which the question was asked and now and quite some time later, because I really had no knowledge… 
- 
		10 votes4 answers1166 viewsA: How to sort the data of a query by predefined values?It would be something like that: SELECT * FROM usuarios INNER JOIN estados e on e.id = usuarios.estado_id ORDER BY e.sigla = 'MG' DESC, e.sigla The reference is here.… 
- 
		7 votes2 answers263 viewsA: In a MVC structure, can we create a model that represents a View (SQL)?In theory, it can. Views in Mysql can insert and update records. Only cannot delete records from the tables involved. Of course the mounting of the MVC pattern on top of a View in SQL needs to be… 
- 
		2 votes1 answer294 viewsA: What is the purpose of the Onmodelcreating method and how does it work?According to MSDN documentation on: This method is called when the model for a derived context has been initialized, but before the model has been locked down and used to initialize the context. The… entity-framework-6answered Leonel Sanches da Silva 88,623
- 
		1 votes1 answer1038 viewsA: Couldn’t perform the Edit because Another user changed the recordActually the problem is with the BDE itself. Not with the database. If the answer were only about the BDE, my recommendation would actually be to abandon the BDE and go to a preview mapping of less… 
- 
		1 votes1 answer525 viewsA: Build Output: Consider app.config remapping of AssemblyThis section is in the web.config: <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> ... <dependentAssembly> <assemblyIdentity… 
- 
		1 votes1 answer161 viewsA: Edgejs and Entity FrameworkWould you like to have a broader view of what the pros and cons of this strategy would be. Is it a good option? Or am I showing myself a lazy programmer? So far this answer is not. I explain: The… 
- 
		48 votes3 answers5198 viewsA: Difference between the use of typeof and isis checks the entire inheritance structure of the object; typeof() returns the exact type of the object. For a better illustration: class Animal { } class Cachorro : Animal { } var a = new… 
- 
		3 votes4 answers11622 viewsA: Is it possible for a Javascript function to call a method that is in the Behind code of the page?Yes. You’ll need the Ajaxextensionstoolbox in your project. First, put on your page the following: <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" EnablePartialRendering="true"… 
- 
		2 votes1 answer455 viewsA: Consult in several fields of the record in a single queryIt’s correct your approach, but I’d do it differently: var chamadosQuery = db.Chamado.Where(!e.StatusChamado); if(filtro != null) { chamadosQuery = chamadosQuery.Where(s =>… 
- 
		2 votes1 answer312 viewsA: Problems with accentuation and Entity FrameworkI have two good ways for you to go: First Option: Phoning the String Here is an issue on which this is widely debated. I don’t like any of the solutions, so I wrote mine: public static class… 
- 
		2 votes1 answer77 viewsA: Set virtual field nameThus: namespace Aplicacao.Core.Dominio { public class SubGrupo { [Key] public int Codigo { get; set; } [Column("TipoFormulario")] [ForeignKey("TipoFormulario")] public int TipoFormularioId { get;… asp.net-mvcanswered Leonel Sanches da Silva 88,623
- 
		1 votes1 answer78 viewsA: CRUD error with . NET MVCDo not use [Index] for primary keys. Does not work. Change to the following: public class Estilo { [Key] public int EstiloId { get; set; } public string Nome { get; set; } public string Local { get;… 
- 
		2 votes1 answer140 viewsA: Problem creating Reportviewer in Asp.net mvcOpen the file ~/Views/Web.config (is not the root directory, it is another) and add the following entry: <configuration> ... <system.web.webPages.razor> <host… 
- 
		3 votes1 answer377 viewsA: Save data through POST in the database with VraptorYou can’t do this: result.redirectTo(this).listAll() The life cycle of a Controller does not allow you to redirect another request to it. It could cause loops infinite of request headers. It is… 
- 
		13 votes2 answers1121 viewsA: PHP7 anonymous class. What are the advantages?The main advantage is precisely not having to define the class to be able to use it. At certain times of the application, you need to use a class to, for example, represent a data structure or… 
- 
		3 votes3 answers176 viewsA: Is there a difference between "str(my_object)" and "my_object. __str__()" in Python?Is there any difference between the method call __str__ (my_object.__str__() regarding the call for str (str(my_object))? Not. According to the documentation, str() flame objeto.__str__(). The… pythonanswered Leonel Sanches da Silva 88,623
- 
		1 votes1 answer183 viewsA: Understanding the same method in Pository and in serviceWhy in addition to using the same method, has also the return? It’s not quite the same method. As you’re using a multilayer application, for this example, it may seem like it’s the same thing, but… jpaanswered Leonel Sanches da Silva 88,623
- 
		2 votes1 answer73 viewsA: Details with @Autowired and Down objectIn fact, this isn’t making much sense: @Autowired private AtividadeRepository atividadeRepository; private AtividadeDAO atividadeRepository = new AtividadeDAO(); In fact, you wouldn’t even pass the… 
- 
		1 votes3 answers2971 viewsA: Shuffling numbers from a list?This answer teaches how to make some algorithms, such as Fisher-Yates, but it is important to note that this algorithm is not 100% random, according to the answer itself. The answer gives other more… 
- 
		2 votes1 answer32 viewsA: What are the errors in this code using EF6?1. Nomenclature of Keys Names used for primary keys are outside the standard Entity Framework Ids search convention. The right thing would be: public partial class InvoiceDetail { public int… 
- 
		3 votes1 answer2062 viewsA: List all properties of a C#object?It would be something like that: public void PrintProperties(object obj, int indent) { if (obj == null) return; string indentString = new string(' ', indent); Type objType = obj.GetType();… 
- 
		2 votes2 answers1921 viewsA: Create Reportviewer in Asp.Net MVCI’m guessing you’ve already installed in your project the package Nuget Mvcreportviewer. The steps to setup and use are here. Examples for configuring the Controller are here. The respective… 
- 
		1 votes1 answer64 viewsA: Automated Deploy - Multi-customer version maintenanceA good start is in Alternative 2 of this reply, where I explain how to create transformations for the archive web.config. Here is one more example. For your case, there would have to be a… 
- 
		3 votes2 answers712 viewsA: Select separated by semicolon to xlsIf the goal is to generate an XLS or XLSX, that which you are trying doesn’t make sense. The correct is use a Nuget package that helps you generate an Excel: PM> Install-Package EPPlus I rode a… 
- 
		1 votes1 answer141 viewsA: recover data from a view table in the controllerIf I were you, I would do table produtos-escolhidos be a form: @using (Html.BeginForm()) { <table class="produtos-escolhidos table-overflow borda table_left span6"> <thead… 
- 
		2 votes1 answer348 viewsA: Questions with Entity Framework (Navigation Properties and Create method)I have been reading several articles and so far I could not understand the real function of the navigation property. Two functions of the navigation properties: Indicate to the Entity Framework a… entity-frameworkanswered Leonel Sanches da Silva 88,623