Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
1
votes1
answer3184
viewsA: How to know the permissions of a scroll in SQL Server
The script below lists all users and their respective roles, both database users and server users, identifying the nature of the user. Must be executed in the database master: SELECT [LOGIN TYPE]=…
-
2
votes1
answer391
viewsA: How to return concrete classes, with populated navigation properties, through Linq queries?
Doing this: select MR.*, M.*, T.* from Auth_MenuRaiz MR Or this: select new { Id = MR.Id, Descricao = MR.Descricao, Ordem = MR.Ordem, Column1 = (int?)M.Id, MenuRaizId = (int?)M.MenuRaizId, Column2 =…
-
2
votes1
answer67
viewsA: Entity Framework Navigation Property
Don’t do this: if (estado == null) { estado = new Estado(); estado.EstadoId = 43; // <--- Evite isso estado.Descricao = "RS"; context.Estado.Add(estado); context.SaveChanges(); } The primary key…
entity-frameworkanswered Leonel Sanches da Silva 88,623 -
2
votes2
answers5600
viewsA: The underlying connection was closed: Unexpected error on a receipt
Add to your connectionString in the archive Web.config: "MultipleActiveResultSets=true;" Example: "Data Source=.\SQLEXPRESS;Initial Catalog=MeuSistema;Integrated…
-
3
votes1
answer357
viewsA: How to force login after running the application?
Make the user leave the session in the event Application_End of your Global.asax.cs: void Application_End(object sender, EventArgs e) { Session.Abandon(); } PS: I have not tested this code. EDIT As…
-
2
votes3
answers1619
viewsA: How to return the last id inserted in the table?
Follow a code to get the last ID generated in SQL Server: function sql_nextid() { $result_id = @mssql_query('SELECT SCOPE_IDENTITY()'); if ($result_id) { if ($row = @mssql_fetch_assoc($result_id)) {…
-
1
votes1
answer292
viewsA: Pick values from Contenteditable fields to send in POST
Yeah, just sort of throw it in a POST command like jQuery: $.ajax({ type: "POST", url: '/MeuController/MinhaActionDeSalvar', data: data, // Coloque os dados modificados aqui success: success,…
-
2
votes1
answer53
viewsA: Can I edit my router at runtime?
The route is not capable of processing a complex entity like the way you’re doing it. If I understand correctly, you want to put the multi-lieutenant model on course, and I believe this approach is…
asp.net-mvc-5answered Leonel Sanches da Silva 88,623 -
4
votes1
answer309
viewsA: Lock or release a controller according to some condition
You can let the user access the Controller no problem. Just create in a business rule that does not allow you to continue: public ActionResult AdicionarCapitulos(int id) { var publicacao =…
-
1
votes1
answer32
viewsA: Error using Rsaprotectedconfigurationprovider
To call the functions: btnCripto_Click(object sender, EventArgs e) { new cifrawebconfig().ProtegerConfiguration(); // new cifrawebconfig().DesprotegerConfiguration(); } They can be called on…
-
1
votes1
answer256
viewsA: Abas Asp.Net MVC x Asp.Net Webforms Ajax Toolkit
First, in MVC there is no Code Behind. Second, the manipulation of tabs, between dead and wounded, is an abstraction of a JS code applied to events within an HTML in a controlled way. Third, it’s…
-
2
votes3
answers2635
viewsA: How to put my ASP.NET site online
After hearing the author of the question, I discovered that the hosting plan is Linux, which (until then) does not support a server that runs ASP.NET MVC properly. Use Azure for free to host your…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
0
votes1
answer358
viewsA: How to get the value of the date field?
Use as follows: Video.PreencheCampos(nIDMedia, txt_descricao.Text, txt_endereco_link.Text, cl_inicio.SelectedDate, cl_fim.SelectedDate); } See more about the SelectedDate here.…
-
1
votes2
answers146
viewsA: Mapping a List<long> in LINQ to SQL - Windows Phone 7.1
In case, how would I map correctly the field IList<long> Tempos , since it is not a simple field, it is a long list, or would have to create a class (Tempo, for example) and treat as a 1 x N…
-
3
votes1
answer486
viewsA: How to extract the numerical part of a monetary value?
Change to the following: var r = new Regex(@"[0-9]*(\.[0-9]{3})*(,[0-9]{2})?$"); Here is a functional example of regular expression.…
-
3
votes1
answer622
viewsA: Master Page does not appear in the list when I try to associate it to a view
At Razor, the model of Master Page is not used. What exists are files from Layout, used by View to build. Unlike Master Pages, where content sections were specified using a set of tags of their own,…
-
1
votes2
answers803
viewsA: Error 4 The type 'System.Data.Entity.Dbcontext' is defined in an Assembly that is not referenced
Open your Package Manager Console (from the Visual Studio menu: View > Other Windows > Package Manager Console) and type the command: Update-Package -reinstall Entityframework…
entity-framework-6answered Leonel Sanches da Silva 88,623 -
13
votes2
answers5369
viewsA: Communication with Pagseguro
I set up a Nuget package that does the shipments to Pagseguro, based on their Github: https://www.nuget.org/packages/Uol.PagSeguro The sources are here. Creating a Request These are the steps to…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
3
votes2
answers460
viewsA: Build possible combinations
Let’s work on that one Model Categoria, placing the inverse property of options: public class Categoria { public int Id { get; set; } public string Nome { get; set; } public bool Primeiro { get;…
c#answered Leonel Sanches da Silva 88,623 -
3
votes1
answer4024
viewsA: Set the selected value in a Selectlist (Dropdownlist)
Change the View code so you can write to the property Selected: @Html.DropDownListFor(m => m.ModeloID, ((IEnumerable<SelectListItem>)ViewBag.ModelosVeiculos) .Select(option => new…
-
4
votes1
answer804
viewsA: Include Problem in Entity Framework
Use another form of Include to load to the last level: var fornecedor = _db.Fornecedores .Include(f => f.Endereco.Cidade.Estado) .FirstOrDefault(x => x.Id == id); Don’t forget to add…
-
2
votes1
answer158
viewsA: Multitenancy with Entity Framework
If you cannot uniquely identify any and all records of the entities in your application, something is very wrong. In the Multilieutenant model, the key does not necessarily need to be composed. The…
-
2
votes2
answers1532
viewsA: Send request get and receive data
What I did is right? Apparently, yes. Just testing to really know. And how now I can be receiving the data from Pagseguro? Sending the request: WebResponse response = request.GetResponse(); See how…
c#answered Leonel Sanches da Silva 88,623 -
1
votes1
answer109
viewsA: Property containing only the Keyattribute attribute resulting in auto-increment column in the database
I believe a column only became auto-increment when the attribute DatabaseGenerated was declared with the signature [DatabaseGenerated(DatabaseGeneratedOption.Identity)]. Not necessarily. Since…
-
1
votes1
answer404
viewsA: Working with Entity Framework, Multithreading and SQL Server in C#
This here: _familiaProdutoAplicacao.RepositorioFamiliaProduto.Todos() It’s terrible in every way for performance, since you make a TABLE SCAN for each consultation. Here I explain why using…
-
2
votes1
answer401
viewsA: Standard Asp.net MVC authentication
Where are these tables? In the directory App_Data a provisional bank in the format LocalDb, but this file is hidden. In the Solution Explorer, click on the button Show All Files to see you: I can…
-
1
votes1
answer824
viewsA: Audit with Entity Framework
Implementation Caseira First you need to create a way to relate the Model log with the Model that will be audited. This can be done by declaring a Model with generic. For example: public class…
-
1
votes1
answer805
viewsA: Popular Dropdownlist and make Insert with the chosen value
Try doing it the old-fashioned way. It’s a little more prolific, but it always works: ViewBag.Generos = db.Genero.ToList(); View @Html.DropDownListFor(model => model.GeneroId,…
-
2
votes1
answer2608
viewsA: Assign execute command to a variable
To use it like this, you need to make your dynamic query admit a return value. Something like this: SET @COMANDO_COMANDO_PAGO = 'select @Pago = count(f.matricula) from matricula m inner join aluno a…
-
1
votes1
answer931
viewsA: Views Typed in ASP.NET MVC, using Viewbag
In this case, you need to create a Viewmodel. A Viewmodel is identical to a Model, but does not store information in a bank. Put into it all the properties of the various Models that will be saved.…
asp.net-mvcanswered Leonel Sanches da Silva 88,623 -
11
votes2
answers6760
viewsA: Error " An error occurred while Processing your request. "
The Azure network assumes that the application that is going up is production, so Debug messages are turned off by default. The way is to manually enable the property customErrors in the…
-
4
votes1
answer201
viewsA: Cloud IDE for C# ASP.NET development
Microsoft has a pre-release of something that will be a Cloud IDE in the future, but is not yet ready by the date of this reply. Coderun disappeared from the face of the earth. His code should be in…
-
1
votes2
answers906
viewsA: Logoff with database registration and cookie deletion behind Session_end() in Global.asax
You can redirect the request to a route that has access to what you need: protected void Session_End() { Response.Clear(); RouteData routeData = new RouteData(); routeData.Values.Add("controller",…
-
3
votes1
answer4456
viewsA: Component to select files or directories
OpenFileDialog. An example of use is here. For directories, it’s called FolderBrowserDialog. There is an example of FolderBrowserDialog here.…
-
1
votes3
answers1158
viewsA: 'NT ANONYMOUS LOGON AUTHORITY' failure in SQL Server 2012 on remote server
Possibly port 1433 on your remote server is not open, or remote SQL Server is not configured to accept remote connections. To configure remote access on the server, follow the steps in this link.…
-
2
votes3
answers2912
viewsA: Select in Entity framework with certain columns
The Entity Framework works with select by default by selecting all columns. If it is still desirable to specify at SQL level which columns should be used, the method SqlQuery of DbSet fulfills that…
entity-framework-6answered Leonel Sanches da Silva 88,623 -
3
votes1
answer85
viewsA: Question Area with Time
This is the best practice of validation and storage as long as I don’t have to worry extremely about security? The safety aspect is more connected to the Controller than to the Model in itself, so…
-
4
votes1
answer159
viewsA: Using Existing Database with Entity Framework
Possible, it is, but you have to pay attention to a few things: 1. You need to have some domain mapped When I refer to domain, I refer to your system having a class for each collection (or table)…
entity-frameworkanswered Leonel Sanches da Silva 88,623 -
18
votes2
answers9392
viewsA: Serialize object list for JSON: A circular Reference was Detected while serializing an Object of type
This is because you possibly have an entity A that references an entity B and that somewhere references A again. To solve, write down the following in the dependent entities: [JsonIgnore] public…
-
1
votes1
answer46
viewsA: Multiple Resources Files in . NET
Not exactly with the same name, but you can have a file with the same prefix, adopting a suffix as differentiation, for example: MinhaResource.Debug.resx MinhaResource.Release.resx In your…
-
3
votes1
answer1713
viewsA: Foreign key on Mongodb
This part of the answer is valid until before version 3.2. For version 3.2 onwards, see the rest of the answer. Using only the findOne() or other methods of find, is not possible because Mongodb…
mongodbanswered Leonel Sanches da Silva 88,623 -
3
votes1
answer128
viewsA: Implement Text Approval Flow
I’m guessing your system uses Entity Framework. I’ll deduce your Model text: public class Texto { [Key] public int TextoId { get; set; } public int UsuarioId { get; set; } public int AdminId { get;…
-
2
votes1
answer44
viewsA: Difficulty with MVC Code Debugging
Check yours in the file App_Start/RouteConfig.cs of its application there is the following rule: public static void RegisterRoutes(RouteCollection routes) {…
-
0
votes2
answers2143
viewsA: Filter Datagridview by Interval Between Dates in VB.NET
No need to pass dates as parameter. You can use the property RowFilter of his DataGridView as follows: DirectCast(OSDataGridView.DataSource, DataTable).DefaultView.RowFilter = "data > #" &…
-
2
votes1
answer197
viewsA: Update Entity framework version
I actually think it is impossible that your Entity Framework is in version 3.5, because the oldest version released is 4.1.10311. Anyway, to update, go to View > Other Windows > Package…
-
2
votes1
answer325
viewsA: Invent Registration Confirmation Procedure
Just to have a little more security and prevent any email from being registered. How to do? Using an attribute called [EmailAddress] in your email field. It validates perfectly if the string is a…
-
1
votes2
answers153
viewsA: View condition does not work
Convert your Viewbag to a strong type before comparing: @{ var itens = ((IEnumerable<TipoDaLista>)ViewBag.Itens); if (itens != null) { ... } else { ... } }…
asp.net-mvc-5answered Leonel Sanches da Silva 88,623 -
2
votes3
answers1368
viewsA: What better way to save a Group object that has Items lists?
My question is, I want the user to be able to link all the Items in the View and only when sending the POST to save everything, that is, save the Group and then the Items classes. What would be the…
-
2
votes1
answer1248
viewsA: How to retrieve content from a cookie
A cookie is a dictionary, so: if (Request.Cookies["pedido"][Id] != null) { minhaInformacao = Request.Cookies["pedido"][Id]; }
-
1
votes1
answer114
viewsA: How to pass multiple viewmodel to a single view?
One inside the other. public class ViewModelPrincipal { public ViewModelDeValidacoes ViewModelDeValidacoes { get; set; } }
asp.net-mvc-5answered Leonel Sanches da Silva 88,623