Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
1
votes1
answer58
viewsA: Save information from tabs
If your models wear Guids, the solution becomes natural. Suppose the following models: public class ModeloPrincipal { [Key] public Guid ModeloPrincipalId {get; set; } } public class ModeloAba1 {…
-
2
votes1
answer165
viewsA: Save windows id Authentication
I would do so: <div class="col-md-3"> @Html.LabelFor(model => model.Perfil) @ViewBag.Id @Html.HiddenFor(model => model.Login) @Html.ValidationMessageFor(model => model.Login)…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
23
votes5
answers6769
viewsA: Should I use GUID or int as the primary key?
What is the advantage of using GUID as the primary key? Perks: Eliminates classic primary key problems IDENTITY, because the record limit increases considerably (about…
-
14
votes3
answers51716
viewsA: SQL Server - Check duplicate data in two simultaneous fields
select CPF, MAT, count(*) from Tabela group by CPF, MAT having count(*) > 1
-
1
votes1
answer2760
viewsA: Return after Httppost in Partial View
The error seems quite simple: you are not returning to View all because it is using an improper construction, in this case, this: @{Html.RenderPartial("PartialView", new Model());}…
-
2
votes2
answers2331
viewsA: How to use the nhibernate Fluent appropriately?
nhibernate is not good for load of data on demand the way you want it, which Entity Framework does well. In the case of your getVendas(), Entity Framework performs the load as follows: Performs a…
-
5
votes2
answers2661
viewsA: What are the advantages and disadvantages of using transaction explicitly
Perks: Security in operations involving multiple changes to different data elements, preventing data from being entered incomplete due to systemic failures; In case of physical equipment failure, it…
sqlanswered Leonel Sanches da Silva 88,623 -
3
votes3
answers1752
viewsA: Alert message in Asp.net mvc
The jQuery UI has the great Dialog who does it for you: http://jqueryui.com/dialog/#modal-confirmation <script> $(function() { $("#dialog").dialog({ resizable: false, height: 140, modal: true,…
-
1
votes1
answer437
viewsA: Problem to create database using Entityframework with configuration by Dbconfiguration
You have not specified in any way how this(s) context(s) should(m) be created(s). There are some ways: 1. Enabling Migrations In Visual Studio, go to View > Other Windows > Package Manager…
-
3
votes2
answers1837
viewsA: IIS error page 404
Has. In your file Web.config, add the following: <system.web> <customErrors mode="On" > <error statusCode="404" redirect="~/SeuControllerDe404" /> </customErrors>…
-
11
votes2
answers7925
viewsA: How to run a PHP application on IIS?
This is the hardest way. Try following steps using the Windows Platform Installer: http://www.microsoft.com/web/downloads/platform.aspx At the top of the window Web Platform Installer, click on…
-
1
votes4
answers661
viewsA: How do I execute a method at the end of each method in my class C#
Using a generic method in the parent class: public void Metodo<T>(T t) where t: IInterfaceClasseFilha { MetodoAntes(); Metodo(t); MetodoDepois(); }
-
2
votes2
answers1351
viewsA: Print queries
The simplest way is through a Javascript link: <a href="javascript:window.print()">Imprimir</a> To avoid the title being printed on the page, use the following setting in your Layout:…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
1
votes3
answers2710
viewsA: How do I create a view in mysql by taking data from 4 or more different tables?
create view minha_view as select e.id, e.razao_social, i1.qtd as ensinando_a_contar_qtd, i2.qtd as matematica_qtd, i3.qtd as fisica_qtd, i4.qtd as quimica_qtd, i5.qtd as historia_qtd,…
-
2
votes2
answers221
viewsA: What is the reason for using Dbmigration in Codefirst?
What is the purpose of using DbMigration when a project is being developed using Code First? The objectives are not to technologically depend on a database and not to manually control the history of…
-
7
votes1
answer404
viewsA: Code First Mapping with Data Annotations
[ComplexType] Specifies that the class in question is a complex type, used for the construction of several others Models. For example: [ComplexType] public class Address { [Key] public int AddressId…
-
6
votes2
answers5236
viewsA: Relationship N for N and One for N with Codefirst Data Annotations
Thus: public class Movimentacao { [Key] public int MovimentacaoId { get; set; } public int ProdutoId { get; set; } public int UsuarioId { get; set; } public virtual Produto Produto { get; set; }…
-
10
votes4
answers1443
viewsA: Should an enumeration be constant in the lifetime of the solution?
What problems could this [modification of an enumeration] cause? It depends on how this enumeration is modified. If the object uses enumeration to persist database data, for example, adding new…
-
4
votes1
answer1214
viewsA: Permissions of users
I’m guessing the following in your Models: Models/Loja.Cs public class Loja { [Key] public int LojaId { get; set; } [Required] public String Nome { get; set; } ... public virtual…
-
5
votes1
answer475
viewsA: What can cause the RU’s performance to fall in this scenario?
This performance problem is well known. By adding the objects one by one, you force the Entity Framework to check the states of all the objects attached to the context, which is bad for performance.…
-
6
votes1
answer3372
viewsA: How to make a complex SQL query in . NET MVC
Suppose a Model of Product: public class Produto { [Key] public Guid ProdutoId { get; set; } public Guid CategoriaId { get; set; } public Guid FabricanteId { get; set; } [Required] public String…
-
0
votes2
answers186
viewsA: DB Dinamico Mongodb
In this link you passed, you would have to change this class to get the desired result: @Configuration public class SpringMongoConfig extends AbstractMongoConfiguration { public @Bean MongoDbFactory…
-
3
votes2
answers10109
viewsA: Set Value Local SQL Server Variable
The message is clear. Just don’t use SELECT to assign value and to return data: SELECT @VariavelLocal1 = SELECT COUNT(TesteId) FROM Table), @VariavelLocal2 = 1 SELECT @VariavelLocal1 +…
-
0
votes1
answer762
viewsA: Aspnet Identity Roles - Custom
The way to extend Roles is different in ASP.NET Identity. It is used Controllers + a class IdentityManager: public class IdentityManager { RoleManager<ApplicationRole> _roleManager = new…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
1
votes2
answers273
viewsA: Class that selects the product name or code or value
Create 3 variations of your function: public List<Produtos> selectFilter(string nomeProduto) { ... } public List<Produtos> selectFilter(int codigoProduto) { ... } public…
c#answered Leonel Sanches da Silva 88,623 -
0
votes2
answers6339
viewsA: Column charts (Bootstrap)
There are some. I’ll put some for you: https://www.nuget.org/packages/DotNet.Highcharts/ https://www.nuget.org/packages/Highcharts.Net/ https://www.nuget.org/packages/HighCharts/ Or the following…
-
8
votes1
answer2783
viewsA: How to create a login and password page in ASP.NET?
I’ll give you an example of the login infrastructure I have here. It’s basically a Controller, plus basic access providers based on Membership. It’s an old approach, but very didactic. First of all,…
-
6
votes1
answer761
viewsA: How to implement an update LOG with ASP.NET MVC?
Step 1. Create a Model to register the shares namespace SeuProjeto.Models { public class ActionsLog { [Key] public Guid ActionsLogId { get; set; } public String Controller { get; set; } public…
-
37
votes2
answers18428
viewsA: What is MVP and MVVM?
Basically, the difference is that MVC has the architecture based on Controllers, whereas the MVVM has the architecture based on Viewmodels, and MVP has an extra layer of presentation, called…
-
0
votes2
answers888
viewsA: Error including sum of values in the footer of a gridview
The problem is not the footer itself. It is the loop iteration. Consider changing the for by a foreach, which is safer: foreach (GridViewRow linha in gvcarteira.Rows) { // converte o preco e a qtde…
-
4
votes1
answer122
viewsA: How can I call functions that are after the same function?
This: def paintball(): print "Olá" adeus() def adeus(): print "Adeus" paintball() It works, after all, adeus() is before paintball(), and the analysis of function names is only done at runtime. Now,…
pythonanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer74
viewsA: Failure to popular a gridView
Change to the following: var pa = from ac in bc.acao where ac.codigo == cod select new { Ação = ac.codigo, Empresa = ac.empresa, Tipo = ac.tipo, Data = ac.data, Hora = ac.hora, Abertura =…
-
3
votes3
answers1618
viewsA: How to intercept exceptions when working with the Entity Framework?
You can intercept any and all exceptions in your Controller common implementing a override for the following method: protected override void OnException(ExceptionContext filterContext) { /* A…
-
4
votes2
answers1269
viewsA: Which Pattern is used to validate business rule?
The @utluiz response is correct within a context in 3 layers (presentation, service and data), but as we are talking about MVC, the validation should be done, essentially, in the Model, but not just…
-
4
votes1
answer2843
viewsA: Sublime problem to run python code
Python path is not in your PATH (environment variables). See the screen below to configure:
-
2
votes1
answer140
viewsA: Validate delete in controller, return html helper
Put in the View: @using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) <div class="form-actions no-color"> <input type="submit" value="Delete" class="btn…
-
2
votes1
answer154
viewsA: Bank table does not update
You are wrong. Modify your code to the following: bco.Entry(papel).State = System.Data.Entity.EntityState.Modified; bco.SaveChanges(); The same goes for carteira: bco.Entry(crt).State =…
-
14
votes2
answers28085
viewsA: What are schemas? What are the advantages of using it?
What are Schemas? They are collections of objects within a given database, which organize various aspects and are important for security segmentation, facilitating the administration of objects and…
-
1
votes1
answer89
viewsA: Use only one parameter
First of all, I would Posicao be a default parameter: Shared Function CarregarListaDominioAnalise(ByVal Idioma As Integer, ByRef Controle As ListControl, ByVal Dominio As Integer, ByVal Habilitado…
-
2
votes1
answer959
viewsA: This Assembly does not allow partially reliable callers
One option is to insert into Web.config the following: <trust level="Full" originUrl=""/> The error happens because the application may be set to Medium Trust. If it still doesn’t work, change…
-
0
votes2
answers669
viewsA: Infinite Loop in Event
It’s weird this code. The correct thing would be to fire the Timer with Enabled, and Elapsed receive a Handler typical, in this case, ElapsedEventHandler, thus: public event ElapsedEventHandler…
-
1
votes1
answer116
viewsA: Place a decision control inside a lambda expression
I’m not sure what the comparison with _cnpj, but I think the line below is very close to what you need. .Where(cn => (cn.x1.a1.o2.NumOs == Convert.ToInt32(_osparceiro)) && (_cnpj == "" ||…
-
0
votes2
answers326
viewsA: Drivers for bank connection via ASP Classic
Well, the newer the driver, the more versions of SQL Server your application will have compatibility. I think this is the logic. Native Client is the driver with the highest compatibility spectrum…
-
4
votes1
answer247
viewsA: How to use Reflection
There is another question that answers this very well, with more details, but the purpose of this answer is to be a little faster and more succinct than the following link: What is Reflection, why…
-
3
votes3
answers1128
viewsA: Entity Framework - Update nested lists
First, make sure that Image refer Region with cascadeDelete enabled. This is an example of Migration: CreateTable( "dbo.Images", c => new { /* Coloque a declaração das colunas aqui */ })…
-
0
votes2
answers285
viewsA: Detect generated event in another class
I don’t know your class C#, but I’ll assume something like that: public class ClasseEmCSharp { public Dados dados = new Dados(); public delegate void EventHandler(object sender, EventArgs e); public…
-
0
votes2
answers2101
viewsA: How to decode an image in Base64
Basically that’s how: public void NewPost(Post post) { post.Image = post.Image.Replace("data:image/png;base64,", ""); byte[] bytes = Convert.FromBase64String(post.Image); Image image; using…
-
2
votes1
answer46
viewsA: Which reference to import into Tableattribute?
using System.ComponentModel.DataAnnotations.Schema; Remember to adjust your Framework to version 4.5.
-
20
votes1
answer8416
viewsA: How the Lazy Load Entity Framework works
In Entity Framework the lazy load (Lazy Load) is configured by default. Suppose a Product Model as the example below: public class Produto { [Key] public Guid ProdutoId {get;set;} public Guid…
-
2
votes2
answers2093
viewsA: Send file from one server to another
If the server will download, implement the methods: public ActionResult DownloadFile() { FtpWebRequest objFTP = null; try { objFTP = FTPDetail("Arquivo.txt"); objFTP.Method =…