I have a web app that currently uses the current HttpContext to store a LINQ Data Context. The context is persisted for the current request, on a per user basis, per Rick Strahl's blog:
string ocKey = "ocm_" + HttpContext.Current.GetHashCode().ToString("x")
Thread.CurrentContext.ContextID.ToString();
if (!HttpContext.Current.Items.C...
I'm looking for a good Entity Framework repository code sample or template.
...
Hello,
In my project I have 'Player'(PlayerID and data) table, 'Games' table (GameID, Name) and I made a many to many table 'PlayerGames' (PlayerID, GameID - I created the forign keys relations)
PlayerID and GameID are primary keys in their tables and the tuple (PlayerID,GameID) are primary key in 'PlayerGames' Table
I tried to map th...
I'm getting started on Linq to Entities and the example references a namespace called System.Data.Objects. My environment doesn't include this namespace and I can't find the DLL that contains it. Anywone know where I'd find it?
...
Back in the old days (i.e. last month) I'd bind my winforms grid to a dataset and be off and running. By default the grid contents could be updated. (similar to an Excel spreadsheet)
But, if I bind a grid to a Linq datasource (either Linq to SQL or Linq to Entities) my winforms grid is locked into a read-only mode. How can I enable an...
Consider two tables Bill and Product with a many to many relationship. How do you get all the bills for a particular product using Entity Sql?
...
Hello,
I am very new to Entity Framework and am wondering about the basic concept of Table Per Type Inheritance and how the entity relates to other tables.
In the physical database the relation works like the following...
Person (Person ID PK)
Customer (Customer ID PK, Person ID FK)
Order (Order ID PK, Customer ID)
My question is bef...
So I'm trying to work on a sample app. Trying to dig into ADO.NET Entity Framework. I get an employee back using a method with LINQ like this:
public IList<Employee> FindByLastName(string lastName)
{
IList<Employee> emps;
var e = from emp in _ctx.Employees where emp.LastName == lastName select emp;
em...
Finally checked out L2E framework and ran into problems almost instantly.
Yeah, i know... i should read some books before.
Situation:
entity with props -> id and name.
entity is mapped to table, which has id and name columns.
sproc, which returns ONLY id column.
Problem:
ObjectResult<MyProp> result = _container.MyStoredProced...
I'm starting on a small windows forms project that makes extensive use of editable grids. I want to use Linq to Entities, but while it's trivial to bind a grid to the Linq query it's read-only. I couldn't figure out a good way to have an editable grid that auto-updates the database. (I hacked a work-around where I copy the data into a...
1) Binding to The following populates a READ ONLY WinFrms grid:
Dim query = (From profile _
In db.profile _
Where profile.employee.employeeId = employeeID _
Select profile.description)
Me.DataGridView.DataSource = profileQueryList
2) Binding to the entity itself makes the WinForms gri...
How do you map a table called category with Id as Primary Key which has self reference called ParenCategoryId using LinqToEntity?
...
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 Entities.table object holds the right data though, it just doesn't reflect on the ListBox.
Any ...
Hi there,
I have a .NET Entity Data Model set up with relationships so that I don't need to manually join entities in my LINQ queries. The LINQ query below references another table CustomerUserField:
from c in Customer.GetCustomer(this.ClientId, intRecordId)
select new
{
c.TitleId,
c.FirstName,
c.LastName,
c.Phone,
c.MobilePh...
Hey,
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 CreatePage(int projectId, string pageName, DateTime createdDate, int createdBy, DateTime up...
I am binding a Winforms Grid to an entity. (For reasons I won't go into here it must be bound to the entity, not the result a query) The code is as follows:
grid.DataSource = myEntities.entityName.Where("it.field = " & field)
It works, but it obviously isn't strongly typed. Is there a way to define the Where clause of an entity usin...
Hi
I am currently trying to do a nested query, using RIA Services. The first query works but the second doesn't work. I assume it is because the second query doesn't have the 'ClassAssignment' data object or something?
My questions:
Why would this not be working?
In future I would like know, how is RIA working under the covers, how do...
Hi there,
I would like to make one database call to retrieve the following data, but I'm struggling to figure out what the LINQ should look like. Here's my current implementation (I know it's bad!!):
var photos = from photo in entitiesContext.Photo
join pg in entitiesContext.PhotoGallery on photo.PhotoGallery.PhotoGalleryI...
Hi,
I am having problems querying many-to-many relationships in Linq To Entities.
I am basically trying to replicate this query using Linq:
Select *
FROM Customer
LEFT JOIN CustomerInterest ON Customer.CustomerID = CustomerInterest.CustomerID
LEFT JOIN Interest ON CustomerInterest.InterestID = Interest.InterestID
WHERE Interest.Intere...
I'm having trouble converting the following SQL-statement to LINQ-to-entities:
SELECT l.*
FROM locations l
WHERE l.id NOT IN (/* array of ids */)
In LINQ, I would like to see something like (where myCollection is a generic list of items to be excluded):
IQueryable<Location> locationQuery = from l in DataContext.Location
...