using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using ///what here
public static class CompiledQueries
{
public static Func<DataContext, int, IQueryable<Foo>> getFoo =
CompiledQuery.Compile(
(DataContext db, int ixFoo) =>
(from f in db.Foo wher...
I have a 2 Entity : Person (Id, CategoryId) and Category(Id).
Now when I try to insert a new Person with only the Id and CategoryId it throws an exception about the Person having a relationship with Category.
The following code doesn't work:
Person newPerson = new Person();
newPerson.Id = 1;
newPerson.CategoryId = 1;
context.AddToPer...
Hey!
I have this LINQ-query:
bool? a, b, c;
from i in _ctx.SomeEntitySet
where
(a == null ? true : i.IsA == a) &&
(b == null ? true : i.IsB == b) &&
(c == null ? true : i.IsC == c)
select i;
I only want to take the condition IsX == x in...
I have this LINQ-query:
// types...
LinkedList<WeightedItem> itemScores = new LinkedList<WeightedItem>();
var result = from i in _ctx.Items
join s in itemScores on i.Id equals s._id
orderby s._score descending
select new ItemSearchResult(i, s._score);
// this fails:
...
I need to determine if any of the Lists contained in the Dictionary contain the specified value. I'm new to LINQ, so is the following the correct way to achieve this?
Dictionary lotsOfStuff = new Dictionary<string, List<string>>();
string searchString;
// populate lotsOfStuff and searchString...
// detemine if any of the values of lot...
I'm running ASP.NET MVC 2 Preview 2 (With VS 2010 Beta 2) using Entity Framework.
Earlier yesterday, for some unknown reason, a single page in my app started to load very slowly on my host.
The problem is, this only occurs on my host and I haven't changed anything for it to load slow.
Here is the action that is loading very slow:
pub...
Helo,
i have the following code which should filter entities. Half of the code is working by i'm trying to refactor my code to get some sort of 'subfilters'.
Basically i have the following call to filter a Users entity collection:
var result = ctx.GetUsers().WithGroups("Administrators","Users").ToList();
WithGroups has the followin...
I am using the following code to extract data from my database using entities. If a record isn’t found it throws the following exception “Object reference not set to an instance of an object.” I can catch this to stop it causing problems but would rather modify the code to not have the problem. Can I change the Linq query so that it is m...
Hi, I have the following two tables (basic outline):
Tbl_CategoryType
ID
LevelID
Description
Tbl_Levels
ID
Name
Basically, I want to present all of the information in the Tbl_CategoryType table while referencing the Tbl_Levels.Name data based on the Tbl_CategoryType.LevelID number.
I have tried using a join in my repository as below...
I have an organization chart tree structure stored in a database.
Is is something like
ID (int);
Name (String);
ParentID (int)
In C# it is represented by a class like
class Employee
{
int ID,
string Name,
IList < Employee> Subs
}
I am wondering how is the best way to retrieve these values from the database to fill up the C# Obje...
First question to SO, I hope I'm doing this right. ;)
Regarding System.Data.Entity.Design.EntityStoreSchemaFilterEntry :
I'm looking for some detailed documentation on this class. The MSDN docs have nothing but an indication of what properties exist and their data types. I want to create a well-defined list of filters for
EntityStoreS...
IQueryable<WebEvent> mySearch =
eventDC.GetBooks()
.Where(p => p.Price.Any(d => d.EventDatetime.Month == fromDate.Month
&& d.EventDatetime.Year == fromDate.Year))
.WithGroup(groupId)
.OrderBy(p => p.Price.Where(r => r.Datetime >= fromDate)
.Or...
I have two entities, Parent and Child, in Entity Framework.
The parent has a collection of Child entities.
In my query, I want to return only the Parent entities (the fully typed EF types) and also the Count() of the Child entities (this could be set to a property on the Parent), but I only want to do this in one call to the database, ...
I have run into this problem:
Custom Methods & Extension Methods cannot be translated into a store expression
Basically I have some complicated LINQ queries, so wanted to break them down into subqueries which are implemented as methods that return IQueryables. My hope was then these IQueryables could be composed together in a LINQ stat...
I'm using LINQ to Entities in the Data layer of my application, but am getting hammered by a NotSupportedException in a call to results.ToList(). Here is the function causing the exception:
public List<Organization> GetByLocation(Location l)
{
using (Entities entities = new Entities())
{
var results =...
I am trying to run the code in there selected answer but can't figure it out
link text
Here is my code:
using System;
using System.Data;
using System.Data.Objects;
using System.Configuration;
using System.Linq;
using System.Linq.Expressions;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web....
If I have three classes in entity framework.
class Base {}
class Left : Base {}
class Right : Base {}
and I call DBContext.Bases.ToList();
This returns all instances of Base fully typed into their associated inherited types, as some people have noticed, the performance of EF on large inheritance structures is not great to say the l...
I'm using EF 4 and I need to find a way to maintain deferred execution and project into another type.
This is my existing code:
AppointmentRepository appointmentRepository = new AppointmentRepository();
var appointmentGridItems = from a in appointmentRepository.ListAppointments()
select new AppointmentGridIte...
I am using EF with WPF.
How should I create a ListBox that shows both Contacts and Persons?
My question is rather how to retrieve it and create the CollcetionViewSource(s).
I know I will have to use ItemTemplateSelector, that's less what I care, what I really care is the retrieval, but any tips on the representation will be welcommed as...
I have one query on my page that takes at least a half second to execute using EF 3.5. When I used a stored procedure the speed was noticably faster. It is a very complex query. Will there be any performance improvements in the upcoming EF 4.0? And does EF 4.0 really beat out 3.5 performance wise?
...