Questions tagged as 'entity-framework'

2
answers

How to make a LINQ / lambda and consume it in the view?

I have an object called Radio : public class Radio { public int RadioId { get; set; } public string StreamUrl { get; set; } public bool Ativo { get; set; } public bool Mp3 { get; set; } } I'm doing a select in control...
asked by 09.08.2015 / 14:45
2
answers

Is it possible to work directly with EntityFramework sources?

Is it possible to work directly with Entity Framework and debug sources within your classes and methods? > I downloaded the zip code from it contained in CodePlex . I unpacked it into a folder and in my project I added the project dire...
asked by 27.08.2014 / 23:07
5
answers

Do not allow to record duplicate registrations

I'm developing a system using ASP.Net MVC and Entity Framework. How do I not allow equal data to be written to a table? For example, do not allow login: x to be registered more than once.     
asked by 05.05.2014 / 14:19
1
answer

Error doing UPDATE when I set varbinary variable to 'null'

Follow the code below: var file = Request.Files; var list = new List<byte[]>(); for (int i = 0; i < 4; i++) { if (file.Count > i) { list.Add(ConvertTo.Bytes(file[i])); continue; } list.Add(null); }...
asked by 13.11.2017 / 21:21
2
answers

How to update all records of all tables that have FK from a table

I have the following tables: CREATE TABLE Contrato ( [Id [int] NOT NULL IDENTITY, [Nome] [varchar](150), [Ativo] [bit] PRIMARY KEY ([Id]) ) CREATE TABLE [dbo].[ItemContrato] ( [Id] [int] NOT NULL IDENTITY, [ContratoId] [int], [No...
asked by 25.08.2017 / 20:51
1
answer

Use IEnumerable or ICollection?

I want to create a 1x N mapping using the fluent API Entity Framework , something like: a shopping cart has several products. In my cart class, I have a navigation property , which is a collection of products: public class Produto {...
asked by 14.03.2017 / 12:41
1
answer

How to optimize this code?

Is there a faster (performative) way of comparing the current value with the previous value (of the bank) with Entity Framework ? Instead of selecting Id by Id (as Discount property of the code below), check the array...
asked by 18.11.2015 / 20:08
1
answer

Entity Framework 6 tries to insert FK

I have a small application in C #, WPF and EF6. I'm using Code First , but I'm having a hard time creating a relationship. Look at my code, of the classes I want to relate: I am editing for the final version, if anyone has the same doubt....
asked by 23.07.2015 / 03:44
1
answer

What's the difference between using SaveChanges () only once after adding data through a foreach and using inside the foreach?

I'm inserting an average of 50,000 records into the database via Entity Framework. And I had a question regarding the following code placements: in the first (1) placement, I use foreach creating objects with their data and adding them (...
asked by 30.06.2014 / 17:00
1
answer

List of Entity Framework attributes for entity mapping

For my Database to be outside the EF convention, and as another system already developed uses it, it is out of the question to change table / column names. I would like to know the available attributes (ex: [Key] , [ForeignKey] )...
asked by 19.10.2015 / 17:46