Questions tagged as 'c#'

1
answer

How to check if a file is an image?

I'm working on an application using ASP.NET MVC and AngularJS and need to ensure that the file upload will be just image files, even if someone sends an extension of another type of ".jpg" for example. I'm getting a MultipartFileData in the...
asked by 22.06.2017 / 15:37
2
answers

interpret account in string C #

Hello, I needed to resolve a string with an account (eg 2 + 2) in C # and return an integer (eg 4) static void Main(string[] args) { string str = "2 + 2"; int resultado = Calcular(str); Console.WriteLine("Resultado => {0}",resul...
asked by 16.07.2017 / 18:56
2
answers

CRUD with images, working with HttpPostedFileBase and byte []

We are using the EntityFramework with CodeFirst and DataBase PostgreSQL. There are some tables that should save images, and POCO classes are referenced as byte array. Up to this point everything is quiet. I can get the images with HttpPostedF...
asked by 25.08.2017 / 05:17
1
answer

Making the insert in SQL Server in a float field?

I have the following problem in my code, I have a textbox that receives the value 0.900 , but when I am writing this value to the bank, it is only recording 900, and I need to record the 0.900 and I can not write this way, the field...
asked by 08.08.2017 / 15:00
1
answer

What are the differences between local functions, delegates and lambdas expressions?

Local functions will be present in C # 7. Given this, I would like to know the main differences between local functions , delegates and expressions lambdas .     
asked by 01.02.2017 / 02:20
1
answer

Entity Framework - What's the difference between EntityState.Modified and Sem EntityState.Modified?

What's the difference between the two? With EntityState: var registro = db.MinhaTabela.Where(a => a.MeuCampo == "Valor_Antigo").FirstOrDefault(); registro.MeuCampo = "Valor_Novo"; db.Entry(registro).State = EntityState.Modified; db.Sav...
asked by 03.02.2017 / 05:17
1
answer

Error in query with Dapper

Well, I'm trying to run a query on com with Dapper and get the following error:    The model item entered in the dictionary is of type 'System.Collections.Generic.List'1 [FertilityRate.Models.Pais]', but this dictionary requires an ite...
asked by 17.01.2017 / 17:26
1
answer

bring menus and active submenus C #

I have to make a query by the menu that I have to bring only the active submenus, see my code. return context.Set<Menu>().Include("MenuGroups") .Where(x => x.Id == id && x.MenuGroups.Any(z => z.Active))...
asked by 30.01.2017 / 16:02
2
answers

How to create 1-N relationship in class with more than one property and even subtype?

I have the following class structure, unconventional but it's in the template I need to solve my problem: Tree: public class Arvore { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }...
asked by 18.08.2014 / 16:28
1
answer

Controller message for the view

I did this: [HttpPost] public void CadastraUsusario(string _nome, string _usuario, string _email, string _nivel_acesso, bool _ativo) { using (RupturaEntities db = new RupturaEntities()) {...
asked by 02.09.2014 / 20:28