Questions tagged [linq-to-entities]

This tag is for questions about LINQ to Entities, which means LINQ queries using the ADO.NET Entity Framework. Note that this is different than LINQ to SQL or other LINQ providers.

This tag is for questions about LINQ to Entities, which means LINQ queries using the ADO.NET Entity Framework. Note that this is different than LINQ to SQL or other LINQ providers.

Related Links

6860 questions
2
votes
2 answers

How do I add a database diagram in visual studio 2010?

I created a database in App_Data, but when I try to generate a diagram for it by right clicking on "Database Diagrams" and then adding a new diagram I get the error: "Could not obtain information about Windows NT group/user" with the error code…
NomenNescio
  • 2,899
  • 8
  • 44
  • 82
2
votes
3 answers

Expression Tree error: Unable to create a constant value of type

Here is the error : Unable to create a constant value of type 'mvcinfosite.ViewModels.GrpSearchHolder'. Only primitive types ('such as Int32, String, and Guid') are supported in this context. How can I resolve that error. I Do a litle example to…
Jean-Francois
  • 1,899
  • 4
  • 35
  • 73
2
votes
4 answers

LINQ-to-entities generic == workaround

I have a following LINQ-to-entities query IQueryable> GetFirstOperationsForEveryId (IQueryable> ItemHistory) { var q = (from h in ItemHistory where h.OperationId == (from h1 in…
Mike
  • 2,468
  • 3
  • 25
  • 36
2
votes
2 answers

Linq to Entity and Loading EntitySets

This is my first attempt at understanding Linq to Entity coming from Net Tiers. Struggling with it but not understanding some of the logic behind it... for instance. When do I…
Rob
  • 3,074
  • 4
  • 31
  • 32
2
votes
2 answers

Querying Child Collections 2 levels deep in LINQ

i currently have a linq to entities model set up as follows each Sample has a collection Of Tests each Test has a collection of Results Each Result has Status property valuing whether it is Available or Completed how would i write a linq query…
Chris McGrath
  • 1,727
  • 3
  • 19
  • 45
2
votes
2 answers

Is this the correct way to insert a relationship in linq

I'm new to linq and I'm trying to write an update statement. I have two tables, tblProject and tblPage. the two are linked via a foreign key in tblPage. So when trying to create a row in tblPage this it th inq query I have public void…
Static Tony
  • 224
  • 1
  • 3
  • 8
2
votes
3 answers

Linq: How to store MD5 hash column in database

I need to put an index on a md5 hash column in the database. I will perform searches on the md5 column. I was going to store the hash as a CHAR(32) but I seen the binary column option as well. Will storing a md5 hash work better in a binary column…
Luke101
  • 63,072
  • 85
  • 231
  • 359
2
votes
1 answer

Strange behaviour with LINQ-to-Entities Include

I've realised that I don't fully understand the Include method in LINQ-to-Entities. For example, take the two code snippets below. I would expect them to produce the same output (though the first version may be more efficient because it avoids…
James
  • 7,343
  • 9
  • 46
  • 82
2
votes
2 answers

Character (string) encoded number to number comparison in Linq

I have this query. levelnumber = (from b in bv.baLevels where b.ba_Level_Code == ("0" + SqlFunctions.StringConvert((double)cl.Level_Num.Value)) && b.isActive == 1 select (b.ba_Level_Code + " - " +…
user957178
  • 631
  • 4
  • 15
  • 27
2
votes
1 answer

Linq to entities: round the sum

I need to round the sum of decimal?. I do: group => new { rounded_sum = group.Sum(f => f.A) == null ? null : (decimal?)Decimal.Round((decimal)group.Sum(f => f.A), 0), } which isn't very nice. Perhaps there is a cleaner way?
ren
  • 3,843
  • 9
  • 50
  • 95
2
votes
4 answers

LINQ to Entities does not recognize the method 'System.String ToString()' method when converting Nullable DateTime

I'm trying to get the Day of the week from a Nullable DateTime and then Joining on a list of days. My solution was to convert it to a DateTime first, but Linq to Entities doesn't like it. LIST is an IEnumerable suggestions? var…
KevinDeus
  • 11,988
  • 20
  • 65
  • 97
2
votes
1 answer

LINQ to Entities returns wrong ID for an entity's child's child

I have a table structure in MySql, set up with foreign keys: Period { Id, Title } Activity { Id, Title, PeriodId } Resource { Id, FileName } ActivityResources { ActivityId, ResourceId } This is set up with LINQ-to-Entities and I have checked that…
James
  • 7,343
  • 9
  • 46
  • 82
2
votes
1 answer

Linq to Entities and update records

I have the following structure: public interface IChainByPreviousId { int Id { get; set; } int? PreviousDeviceId { get; set; } } public class RegisteredDevice : IChainByPreviousId { public int Id { get; set; } public int?…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
2
votes
1 answer

C# Listbox Bound to Entity "Entity Framework"

On my WinForm, I bound my listbox to a Table in Entity on EDMX, but when the table data is changed, I tried to call myListBox.DataSource = Entities.table; myListBox.ResetBindings(); myListBox.Refresh(); but nothing happens in ListBox. The…
Sumesh
  • 61
  • 2
  • 4
2
votes
2 answers

how to get two column values in a single query using linq to entities

I have a member table with columns memberid Firstname( values like john,pop...) secondname(values like ..david ,rambo..) i want to get the firstname and secondname in a single query i want something like this.. john david pop rambo i know…
Glory Raj
  • 17,397
  • 27
  • 100
  • 203
1 2 3
99
100