I have a simple LINQ query on ADO.NET Entity Framework as follows
var result =
from itemA in TableA
join itemB in TableB on itemA.ID = itemB.ID
select ??????
I am trying to select everything from itemA and itemB without specifying all the TableA and TableB.
anything thoughts???
...
Using VS 2008 & .NET 3.5 SP1:
I am using WCF to allow clients to connect to a service that reads and writes database entries using Entity Framework. By default the entities that are generated automatically from the database have the DataContract attribute applied.
Unfortunately many of the fields are exposed are not meant for consumpt...
I'm trying EF with the EFPocoAdapter for the first time. I have a relatively simple TPH scenario with one table and two types, each inheriting from an abstract base class.
My model validates through EdmGen, and my PocoAdapter.cs and xxxEntities.cs files generate fine as well. (well, actually, there are some namespace probems that i'm ...
In a LINQ to entities expression like this:
var vote = (from vote in db.Vote where
vote.Voter.Id == user.Id
select v).FirstOrDefault();
how do you you add a DefaultIfEmpty so that when there's no vote I'd get a default value?
...
I asked this question earlier but I think I phrased it incorrectly, so here is attempt number two. I have the following code:
public User EditUser(User userToEdit)
{
//userToEdit contains values for eagerly loaded contacts entity
User originalUser = (from u in _entities.UserSet.Include("contacts")
...
I am creating my own custom T4 Template that integrates with an ADO.NET Entity Framework Model (.edmx file) included in my MVC Web Application.
For Reference
Please take a brief look at the following two URLs.
Scott Hanselman - "T4 Code Generation Visual Studio Best Kept Secret"
Visual Web Developer Team Blog - Quick Start Guide for ...
Hi
I am trying to attach an entity to the ObjectContext.
When I do so, the following InvalidOperationException is thrown:
An object with the same key already exists in the ObjectStateManager.
The ObjectStateManager cannot track multiple objects with the same key.
I checked in the object state manager and the item does not exist:
//D...
I'd like to merge the following Expression:
// example class
class Order
{
List<OrderLine> Lines
}
class OrderLine { }
Expression<Func<Order, List<OrderLine>>> selectOrderLines = o => o.Lines;
Expression<Func<List<OrderLine>, Boolean>> validateOrderLines = lines => lines.Count > 0;
// now combine those to
Expression<Func<Or...
Suppose I have an employee object with the following properties:
Name - string
Hours - single
Wage - single
I want to add a property, Salary, which equals Hours * Wage. In an ordinary business object, I would simply code that up in the property, but this would presumably wiped out if the class needed to be regenerated.
Is there an EF ...
I have an Entity Data Model being read by an ADO .NET Data Service.
The entity in question looks like this:
**PaidAmount**
Id
FY_1993
FY_1994
...
FY_2030
Is it possible to set a default value so that values of 0 aren't serialized?
I have tried setting FY_1993's Default Value to both 0.00 and 0 but when I view the Entity in the .svc t...
I'm experimenting with the Entity Framework and I want to connect to an Access 2007 database.
The following code is inspired by http://msdn.microsoft.com/en-us/library/system.data.entityclient.entityconnection.connectionstring.aspx
I suspect that I've got the wrong end of the stick...
OleDbConnectionStringBuilder oledbConn = new OleD...
Please read here and here to get a quick overview of my problem and to see exactly what I mean when I say Model Binding from Ajax.
Would it be a bad idea to make the foreign key fields nullable in order to allow for Model Binding from javascript?
For example, we want to bind to a Person object during an ajax call to... (The Person cla...
EDIT: During this post I started
searching on video tutorials on
ASP.NET MVC, EF and LINQ and found
some very useful links which I shared
here. As I believe videos are more
interactive and easier to learn from.
Hope, they'll help.
Guys, please share the resources to get start on MVC, Entity Framework and LINQ. And if you...
Hi,
I'm trying to set up what I think is a pretty simple data model in the Entity Framework. I've got two entities, OrderHeader and OrderLine.
OrderHeader
+---------+--------+
| Name | Type |
+---------+--------+
| Id | Int |
| Name | String |
+---------+--------+
OrderLine
+---------+--------+
| Name | Type...
I have two sql tables Players and Teams joined by a PlayerTeam junction table. A player can be on a team for various years. What's the best way to handle this relationship? I started with a PlayerTeamYear table, but the foreign key reference to both columns in PlayerTeam seems unwieldy, especially as I want to convert this to Entity Fram...
I'm doing a very non-standard build of Entity Framework. I've used EdmGen2 to generate edmx off of a db, and split the component csdl, msdl and ssdl files into their own files. The metadata in the connection string to them looks like this:
C:\Downloads\EDM | filename.csdl | filename.msdl | filename.ssdl
I have a unit test that does not...
How can I do a select in linq to entities to select rows with keys from a list? Something like this:
var orderKeys = new int[] { 1, 12, 306, 284, 50047};
var orders = (from order in context.Orders
where (order.Key in orderKeys)
select order).ToList();
Assert.AreEqual(orderKeys.Count, orders.Count);
I tri...
I'm using the SQLite.net provider and VS Entity Designer to design and code against a sqlite database. At present, a model sqlite database is checked in to the source tree.
However, this is binary which is inconvenient for use with a revision control system.
I'd like to check in a serialized version using sqlite's .dump, but am not sur...
I having a weird problem with Entity Framework with MySql database.
Here's the code that I've got.
public class testbase
{
private testEntities db = new testEntities();
public IQueryable<post> GetRecords()
{
return db.record;
}
}
Here record is a table in my database and this could should return all the rows ...
I have a Silverlight application and I'm using a WCF service to access my database information. For this I'm using EntityFramework. I have a class Items (mapped on my DB table Items) which has an ObservableCollection of Keywords (class mapped on my DB table Keywords) objects.
From the interface I create an Items object with all the pro...