Questions tagged as 'entity-framework'

1
answer

Return from sql in text to model in the entity framework

I have the parents class and the state class: [Table("tb_pais")] public class PaisModel { [Key] [Column("id")] public int Id { get; set; } [Column("nome")] [Required(ErrorMessage = "O campo nome...
asked by 22.08.2018 / 20:19
1
answer

What's the difference between using "equals" vs == in LINQ to Entities?

As I mentioned above, when I say equals of LINQ to Entities I'm referring specifically to the C # reserved word and not to Equals() of System.Object . Source: equals (C # Reference) The following example returns all...
asked by 06.12.2018 / 23:34
2
answers

Lambda Expression X linq

Speaking in terms of performance in the whole (speed, integrity and etc ...), use lambda expressions to query database, is it better in terms above or not or depends?     
asked by 05.06.2014 / 22:06
1
answer

Entity Framework lambda with include return empty collection

I have a select that returns chained data and plays them in a ViewModel created for the simple reason that I can not return all the data in my table, as in the example: var data = _context.Forms .Include(i => i.OrganizationUnit) .Include(i...
asked by 14.02.2018 / 23:52
1
answer

How to do a SUM in different table fields in the Entity Framework?

This is the SQL that I have as an example, would you like to do the same with Linq ? select SUM(iv.precoMediano * oi.quantidade) as total from orc_orcamentoItem oi inner join orc_insumoValor iv on oi.codigo = iv.codigoSinapi where...
asked by 05.10.2017 / 15:17
2
answers

Create a new record based on another with Entity

I need to add some columns to a database as follows: I keep a line of bd in a variable Market novo = new market(); novo = context.Markets.where(blabla).First(); I change a column of the line novo.ParentID = 50; I'm trying t...
asked by 19.09.2017 / 15:07
2
answers

EntityFramework - new table was not created

Following this tutorial tables all correct. Then I went to do a test, I created a new entity, I made update-database and nothing to create the table in SQL Server 2012. I made some changes in the entity, added migrations , tried to...
asked by 18.08.2017 / 15:07
1
answer

Entity Framework Connection String

I'm creating a project using Entity Framework. My question, would be, how can I create a connectionString (for SQL Server for example) and set in my DBContext where it will get from the Web.config file? DBContext namespace Data { pub...
asked by 29.04.2017 / 16:25
1
answer

Entity Framework - LazyLoad with property that allows null

What happens to a search that uses include of Entity Framework in a property that can be null. var ocorrencia = db.Ocorrencia .Include("Pessoa") .FirstOrDefault(c => c.id == 3); This ocorrencia...
asked by 22.03.2017 / 22:50
1
answer

Entity - Multiplicity constraint violated

I'm not understanding the reason for this error in Entity. Could you give me a help?    Error: The role 'OccurrenceHistorical_Target_Operation' of the relationship 'MoradaWeb.Models.Historical_Operation' has multiplicity 1 or 0..1. Mode...
asked by 29.03.2017 / 19:50