Questions tagged [objectset]
24 questions
8
votes
1 answer
Why is this throwing a NULL value exception?
For some reason I am getting the following error at the db.SaveChanges(); instruction:
Cannot insert the value NULL into column 'UserId', table 'XXXXXXXXX_Dev.dbo.Portfolios'; column does not allow nulls. INSERT fails.
The statement has been…

Stephen__T
- 2,004
- 3
- 25
- 48
7
votes
2 answers
How can I create an instance of an ObjectSet?
I am making DAO unit tests in my project and I have a problem using the ObjectSet class. I have to create a new ObjectSet but in order to do this, I must not connect to the DB. So I can not use the BusinessModelContainer's CreateObjectSet() method.…

Adriano
- 207
- 2
- 12
5
votes
1 answer
Get Objects from an ObjectSet by specifying a Range in EF
I am trying out EF 4.0.I have an Employee Object and using EF I am getting the Employee ObjectSet by simply calling
Context.Employees
Now the above call will spit following sql query
select * from Employees
The above query works fine and I don't…

NiK
- 1,827
- 1
- 20
- 37
4
votes
3 answers
Entity Framework: ObjectSet and its (generics) variance
I use: EntityFramework + POCO
Here is the thing:
public interface IBaseType
{
int Id { get; set; }
}
public class BaseType : IBaseType
{
public virtual int Id { get; set; }
}
public class DerivedType : BaseType
{
}
The problem:
public…

Jefim
- 3,017
- 4
- 32
- 50
3
votes
1 answer
Why does hard coding a function expression speed up query by four minutes?
I am using Dane Morgridge's repository code as a parent to my repository class. In the parent class--EFRepository--there is a method that calls an ObjectSet's Where clause passing in a Func method. Upon calling this code and then assigning it to my…
user134363
3
votes
2 answers
Do ObjectContext and ObjectSet offer advantages over DbContext and DbSet?
I am currently finalizing the architecture of my new application that will be using Entity Framework as its ORM. However, I am a little bit confused with respect to whether I should go with the default option (DbSet and DbContext), or use a "tricky"…

Nirman
- 6,715
- 19
- 72
- 139
3
votes
4 answers
MusicStore 'System.Data.Objects.ObjectSet<....>' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument
I'm following the MusicStore tutorial I'm already on the Part 8 of the tutorial. I got this error when I tried to add the ShoppingCart class.. I tried to google for a possible solution but failed to find a clean one T_T .. based on my research I'm…

bot
- 4,841
- 3
- 42
- 67
3
votes
1 answer
Generic Repository vs. ObjectSet
There seems to be a common agreement in the blogosphere, that one of the great features of the Entity Framework 4 is the ability to create generic repositories on top of the generic ObjectSets. Example implementations of generic repositories are…

Peter
- 43
- 7
2
votes
1 answer
ObjectSet.AddObject(T) problem?
The ObjectSet.Single(predicate) doesn't work (the Where() and toList() methods as well) unless i write it this way:
ObjectSet.Cast().Single(predicate)
But i don't know what to do to resolve the problem with the AddObject and…

Rahma
- 255
- 3
- 21
2
votes
1 answer
ObjectSet library is not being found?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ModelLayer.PocoModels;
using System.Data.Objects;
namespace ModelLayer
{
public class NorthwindDataContext : ObjectContext
{
…

Vishal
- 12,133
- 17
- 82
- 128
2
votes
2 answers
Attach additional ObjectSets to ObjectContext from separate project
I hope this makes sense. I have a ASP.NET web application that uses Entity Framework. I have added a couple of custom tables to the db and created a separate project to handle the CRUD operations for those tables. I chose the separate project…

trevorc
- 3,023
- 4
- 31
- 49
2
votes
1 answer
Entity Framework 4.0 - Including entities - Eager loading problem
We have 3 tables in our db that each have an entity in our edmx. To illustrate my problem, imagine 3 tables:
Table: Make
Fields:
makeID
make
Table: Model
FIelds:
modelID
makeID foreign key
model
Table: Car
carID
modelID foreign key
car
Our…

Chris Klepeis
- 9,783
- 16
- 83
- 149
1
vote
1 answer
Explanation of the usage of it. while using ObjectSet<>.Where()
I have the following piece of code which is working fine:
ObjectContext octx = new ObjectContext("name=PublisherModelContainer");
ObjectSet authorSet = octx.CreateObjectSet();
ObjectQuery q =…

Siddharth B
- 344
- 3
- 11
1
vote
1 answer
ObjectSet's Where() method and memory
I'm using an ObjectSet's methods to do various queries in a table, namely, selecting a few records from it as such:
var results = Repository.Find(c => c.Enabled == 1).ToList();
Here is the Find method of my repository:
public IEnumerable…

Francis Ducharme
- 4,848
- 6
- 43
- 81
0
votes
1 answer
ObjectSet EntitySet contains all duplicates
I have the following data in a SQL table called tb_CField
CampaignID FieldName
739 L_extra1
739 L_extra2
739 L_extra3
When I access the data via the Entity Framework (v4), the object context method
oc.tb_CField()
the…

WebInspired
- 13
- 5