Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
2
votes1
answer23
viewsA: Entity Framework - Lazyload with null-enabled property
The Occurrence object will be returned with the Null Person object, or nothing will be returned? By its mapping, nothing will be returned, as the anticipated charge resolution will be by INNER JOIN…
-
0
votes1
answer293
viewsA: connection localDB visual study
Download Microsoft SQL Server Express. In the installation options, check "Localdb". Done that, test again.…
visual-studio-2013answered Leonel Sanches da Silva 88,623 -
2
votes1
answer160
viewsA: How to pass more than one parameter to a Controller?
The right way is by using Viewmodel: namespace SeuProjeto.ViewModels { public class CriarEvolucaoViewModel { public Usuario Usuario { get; set; } public Chamado Chamado { get; set; } public Evolucao…
-
1
votes1
answer69
viewsA: How to identify the Entity that throws the error when saving?
Yes. I’ve already answered that in another question that’s not exactly a duplicate. After implementing, place a breakpoint within the catch. Since there are many entities, probably the error should…
-
2
votes1
answer102
viewsA: Upgrade from many to many with EF 6
The error means that you sent the same object into context Acao twice, in the first object there is no change, and in the second there is change. If you’re just altering an object Diagrama, no…
-
3
votes1
answer122
viewsA: Comparison of Session and Viewstate with String
Because Visual Studio was unable to make the comparison without a prior conversion? Because the return of Session["teste"] is object, nay string. Not necessarily all that is in Session is string, so…
-
0
votes1
answer179
viewsA: Associative Table of Companies and Users, Many to Many
I have answered several times on how to make N to N membership here on the site. Anyway, I’m gonna work this out for you better. There are two ways to define association N to N in the Entity…
-
2
votes2
answers2772
viewsA: Pull data from an input when typing in the field
What you’re looking for is called Typeahead. Usually the solution does not come alone: it accompanies another framework, like Bootstrap. There are some implementations of Typeahead for Bootstrap:…
-
7
votes2
answers6462
viewsA: Create excel file with c#
The best tool I know to do what you need is the Epplus. There are several answers from me on the site regarding. I’ll make a small tutorial for you on how to use. The minimum using (var excelPackage…
-
0
votes1
answer197
viewsA: Mount Regex to change string json
Rode in Fiddle with an idea. It’s not exactly the best, but it’s based on the idea that if I replace the initial quotation marks with apostrophes and serialize, the JSON deserializer will understand…
-
7
votes3
answers1381
viewsA: What is the difference between Data Annotations and Fluent API?
What is the difference between Data Annotations and Fluent API? The approach mainly but there is a conceptual problem in your question because the Fluent API makes use of the namespace…
-
2
votes1
answer366
viewsA: Error in running update-database Migration
Cliente inherits Pessoa: public class Cliente: Pessoa, ISelfValidator { ... } So you can’t determine that Cliente is in a table Clientes. A Cliente will stay in the Pessoas by standard convention:…
-
6
votes1
answer924
viewsA: How to create a runtime class?
Short answer: using System.Reflection.Emit. Long answer: Is this answer here, but I won’t just stick it to you here. I’ll explain the principle. First you need to define the dynamic type builder.…
-
2
votes1
answer120
viewsA: How to know the View() call link. NET MVC
The simplest way to achieve this is through Request.RequestUri.PathAndQuery: ViewBag.shortLink = PresentationServices.Helper.GetCompanyShortLink((int)id, Request.RequestUri.PathAndQuery);…
-
1
votes2
answers978
viewsA: List<Model> Actionresult() MVC
I don’t understand what you want to do with it: public ActionResult Detalhes(PoderesPJ.Detalhes item) { return View(); } Either way, it won’t work. To detail the record, you’d better pass the Id of…
-
1
votes1
answer59
viewsA: Fluent API modeling with reference table
If I understand what you want, that’s it: modelBuilder.Entity<Usuario>() .HasMany(t => t.CartoesCredito) .WithMany(t => t.Usuarios) .Map(m => { m.ToTable("CartoesCreditoUsuarios");…
-
4
votes2
answers1073
viewsA: How to run a python file as an admin?
Windows Run Command Prompt or Powershell with Run as Administrator option. Run the command normally: > python seu_script.py Linux and Mac In Terminal, use: > sudo python seu_script.py…
pythonanswered Leonel Sanches da Silva 88,623 -
2
votes1
answer296
viewsA: Can I consider that my application is in MVC?
First let’s conceptually define what MVC is, and then draw a parallel with your solution. Of our tag mvc: Model-view-controller (MVC) is a model of software architecture that separates information…
-
2
votes1
answer114
viewsA: Date validation
I assume you’re using the Epplus. From what I understand, you are trying to throw the Excel data to a DataTable (because it creates DataTables and DataRows in the middle of it there), but at the…
-
0
votes2
answers96
viewsA: Only allows 5 attempts at key duplication Entityframework? a 6 badge in Savechange()
The opening of the transactional scope is wrong. You do not open the scope from the connection to the database: open from the own . NET, because object handling is not a purely database issue. The…
-
1
votes1
answer678
viewsA: Validation for Textarea using Razor MVC 4
I can’t quite see this approach: @model TClient ... @this.TextArea("motivo").Class("form-control required").Rows(7).Columns(50) The correct would be to strongly type the View: @model…
-
0
votes1
answer706
viewsA: Fill Dropdown from the selection of another Dropdown
I think you have complicated a lot. You could have written the Ajax event like this: @section Scripts { <script> $("#StatePar").change(function () { $.ajax({ url:…
-
2
votes1
answer6563
viewsA: Unable to load file or Assembly 'Entityframework, Version=5.0.0.0 or one of its dependencies
As clarified by comment, the package was not installed correctly. The following command usually solves the problem: Install-Package EntityFramework It is also important to check for the correct…
-
0
votes2
answers50
viewsA: How to create a built-in validation screen?
Using Bootstrap for updating data, you can build your form with modal. Sending information can be done through Ajax using jQuery, for example. It is important to say that you need to treat the…
-
9
votes1
answer6325
viewsA: Problem with Nuget Packages Visual Studio
You possibly moved something from place and lost the reference between directories. Open the . csproj file of your solution as text (in VS or Notepad) and check the directory where the…
-
2
votes2
answers160
viewsA: Icollection<Object> - how to create and use objects within the collection
How do I add a comment to Icollection Comments? Assuming this comment is made at code level only, you can add a Comment through his Controller as follows: var contexto = new MeuSistemaContext(); //…
-
4
votes1
answer239
viewsA: How to configure Entity Framework Mapping 1:N using inheritance
1:n of Pessoa with Usuario cannot be inheritance, unfortunately. Inheritance does not mean multiple cardinality. The inheritance case is something like this: public class Usuario { ... } public…
-
9
votes2
answers223
viewsA: How to get all constants of a class?
Using Linq is very simple: var constantes = typeOf(RolesHelper).GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) .Where(fi => fi.IsLiteral &&…
-
2
votes1
answer455
viewsA: Pass Viewmodel properties to Controller
Now it’s a case of using the Begincollectionitem. You have several answers about, but I will also pass a few steps that may be useful. 1. Put this in a partial, for example,…
-
2
votes1
answer831
viewsA: How to select a select using the ado.net Entity Framework
You should not use the Entity Framework as SQL because it is not SQL. The sentence needs to be rethought. It should start with scheduling including your orders, not orders including scheduling. That…
-
4
votes1
answer102
viewsA: jquery Intellisense does not work in VS2015 Community
Maybe you updated something and the cache lost. Perform the following steps: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv /updateconfiguration C:\Program Files…
-
2
votes1
answer285
viewsA: Fill Grid dynamically with Dapper framework return
DapperRow can be treated as a dynamic object. I took this idea of an old code of mine. Help, but I admit that can do better. I think this is kind of slow. public statis class DapperExtensions { ///…
-
1
votes2
answers409
viewsA: Pass List to Actionresult
This doesn’t fire a POST: <button onclick="location.href='@Url.Action("EditAll", "DeliveryService")'"> Salvar </button> By the way, I don’t understand what the point of using the button…
-
0
votes2
answers143
viewsA: How to disable Forms Authenitcation for the Web API?
Strange you have Formsauthentication configuration in a Web API project. Anyway, to disable Formsauthentication, use: <configuration> ... <system.web> ... <authentication mode="None"…
c# asp.net-mvc asp.net-web-api web.config forms-authenticationanswered Leonel Sanches da Silva 88,623 -
3
votes1
answer278
viewsA: Inserting and updating data in N-N tables (many to many)
As Collections need to be virtual. Also try using plural names: public virtual ICollection<Conta> Contas { get; set; } public virtual ICollection<Pessoa> Pessoas { get; set; } Run some…
-
1
votes1
answer1742
viewsA: How to open file with window.open in a post?
For the tab title case, you can use Javascript. An example using jQuery: var wnd = window.open("data:application/pdf;base64," + data, "_blank");…
-
0
votes1
answer151
viewsA: Unique contexts of authenticated users
What an elegant way to create a context for each user logged into the system where there is no interference from the other? Cookies? Sessions? Cookies would be the best alternative. The data that…
-
2
votes1
answer111
viewsA: Many Exclusion for Many Entity Framework
There is a small conceptual error here, which becomes a significant error when persisting records. When you do: Orcamento.OrcamentoProfissionais.Remove(objParaRemoção) You are only deleting the…
-
6
votes2
answers814
viewsA: What is the most "clean" and clear way to validate entities using the Entity Framework
I need a clear "clean" way to validate entities without polluting entities with Dataannotations, knowing that I am using the Fluent Api to configure them. What do you mean "pollute entities"? The…
-
3
votes1
answer65
viewsA: Save and update entities
Got this right here: db.Set<Entidade>().AddOrUpdate(meuObjeto); Accepts, incidentally, several objects: db.Set<Entidade>().AddOrUpdate(meuObjeto1, meuObjeto2, meuObjeto3);…
-
3
votes1
answer69
viewsA: Timespan: count occurrences at a specific time
I made a Fiddle, but, before using, it is important to explain some aspects. First, it is important to note that pass strings of times is not exactly the best practice, especially because you will…
-
12
votes1
answer6294
viewsA: Multiple INNER JOINS with DAPPER
1º In this code line "cn. Query" I informed 3 classes, it is necessary to also include the fields of the others (Menu and Category) together in select? Not necessary, but the more complete one…
-
3
votes4
answers961
viewsA: how to generate an xml in memory
Writing raw XML (as you did) is bad practice. There is no mention of the DTD, no encoding statement, no definition of namespaces which, however not the case, generates an XML outside the formatting…
-
2
votes2
answers96
viewsA: Entity Framework - tables not created
Your Web.config does not possess a Connection string: <configuration> ... <connectionStrings> <add name="DefaultConnection"…
-
3
votes1
answer198
viewsA: Authorizeattribute in Controlller and Actions
The idea is that attributes in Actions should override the one defined in the Controller, as well as the [AllowAnonymous] makes perfectly. It’s not really like that. [Authorize] is additive, so when…
-
1
votes1
answer735
viewsA: Migration with possible data loss
There are two ways: Remove-Migration Removes the Migration with problems. Also removes the Snapshot database if applicable. To undo the Migration: Update-Database…
-
3
votes1
answer183
viewsA: Update problem with 1 field - EF
This code does not modify anything. You are creating a new object and trying to save this new object using an update operation. As this new object does not yet exist in database, the update…
-
3
votes1
answer261
viewsA: ASP.NET MVC Scaffolding for any table
Yes, using the Entity Framework Power Tools. Only there is a problem: this tool, besides being a Beta, has not been updated to Visual Studio 2015. So, this guy updated the tool for us. The link to…
-
2
votes1
answer135
viewsA: Error while logging in applications
Probably missed the dependency injection. Check in your file Startup.Auth.cs if SignInManager is being instantiated correctly:…
-
1
votes1
answer67
viewsA: How to load a Partialview to create a comment
The beginning is ok, but it will be necessary to change some things so that it makes sense to use as Partialview: @model shanuMVCUserRoles.CommentSet @using (Html.BeginForm()) {…