Questions tagged [dbset]
224 questions
0
votes
1 answer
DbSet to return multiple entries
To return a single entry I use DbSet.SingleOrDefault(l => l.UserName == userName). There must be an equivilent that will return a list of items (assuming there is more than 1). But I can't find it.
What's the Linq call on a DbSet to get a list of…

David Thielen
- 28,723
- 34
- 119
- 193
0
votes
2 answers
EntityFramework, how to decide which dbSet to use with switch/case?
I'm a beginner with EntityFramework and WCF, so I don't yet know how everything works, so I'll try to explain my situation as best as I can..
I have WCF service that uses a database with EntityFramework and I have managed to get it to work just fine…

Juuseri
- 41
- 6
0
votes
1 answer
Conversion failed error when it shouldn't be trying to convert anything
Message "Conversion failed when converting the nvarchar value '\"United States\"' to data type int."
I use entity framework for data access to a SQL DB.
It is set as a string in my table and it is set as a string in my entity.
This is happening in a…

O.Bisseker
- 28
- 3
0
votes
1 answer
Using a Generic Function to query a DBSet in EF5
I have seen various implementations of DbSet but I'm not sure they are what I am looking for.
Basically we have a bunch of DbSet's set up through EF5 Code First approach. I have a task of writing code to check any updates/posts coming into the API…

MattE
- 1,044
- 1
- 14
- 34
0
votes
1 answer
access and query DbSet of DbContext by name
how to access and query a DbSet of DbContext by name (passing a string with the entity name or the fullname)
something like (but this doesn't work)
string myTypeName= "mycustomtype"; //or "mynamespace1.mynamespace2.mycustomtype"
Type myType =…

pinale
- 2,060
- 6
- 38
- 72
0
votes
1 answer
Is there a way to make DbSet.AddOrUpdate case sensitive?
I have a data set (show below) where each record is unique on two fields when considering case senstivity -
var dataSet1 = new DataSet() { Country = "UK", City = "London", ... }
var dataSet1 = new DataSet() { Country = "UK", City = "LONDON", ...…

Rajul Gupta
- 25
- 9
0
votes
1 answer
Why is AsQueryable() for the class DBSet not in the MSDN documentation?
This link describes the class DBSet.This type implements IQueryable, what means, that it has to have an implementation for AsQueryable(). But in the list in the link I cannot find this method.
Can somebody tell me why?

David
- 1,275
- 2
- 17
- 27
0
votes
1 answer
Insert postgres row using npgsql
In my postgres database, the keys for my tables are serial data types that the postgres database autoincrements. Using C#, Npgsql, Entity Framework 6, WPF, linq and EF dbsets (any extension methods?), is there a way to implement a repository method…

harpagornis
- 103
- 3
- 17
0
votes
0 answers
Linq query on DBSet not picking up newly added entries
I have the following piece of code to check if an entry exists in a DBSet and if not, to add it.
As there are some similar entries in the loop, it will try to add the same data more than once, which the linq statement (just after alreadyInserted)…

Weetobix
- 55
- 1
- 11
0
votes
1 answer
Unexpected behavior using DbContext and DbSet
I have two identical sql tables: dbo.Smith_Products and temp.Smith_Products.
I have two identical classes under different namespaces: IMS.Model.dbo and IMS.Model.temp
I am trying to move data from one table to another using Mapper:
var spc…

Chris
- 650
- 7
- 20
0
votes
0 answers
Inheriting dbset to add new methods
I'm trying to inherit a dbset from my dbcontext to codify new methods in it. I wouldn't like to create an extension, I prefer an inherited class to preserve original dbset to other tasks.
I've seen this link:
Inherits from DbSet with the purposes…

lake274
- 11
- 2
0
votes
1 answer
Does NHibernate need no device like Entity Framework's DbSet?
From what I have gathered. the DbSet is a typed entity cache, and on Save, a DbContext polls all DbSets for entities in need of persistence. In NHibernate, the caching and change detection for all entity types are combined in an ISession…

ProfK
- 49,207
- 121
- 399
- 775
0
votes
0 answers
Field type issue in Db entity query
I have a simple query to a DBSet which is giving a typing error. When i debug it gives the following error: "The 'TranNumber' property on 'InventoryAdjustment' could not be set to a 'System.String' value. You must set this property to a non-null…

javier_el_bene
- 450
- 2
- 10
- 25
0
votes
1 answer
Same db context multiple ToTable
I have a product configuration as such:
internal sealed class ProductConfiguration : EntityTypeConfiguration
{
///
/// Initializes a new instance of the class.
///
…

Pete
- 57,112
- 28
- 117
- 166
0
votes
0 answers
ASP.NET MVC How to use DbSet with multiple conditions
I have a Person model in ASP.NET MVC, and I'm working with DbContext, and I have
a DbSet to this model.
I have first name, last name, nick name fields.
I want to know how can I select persons with DbSet with several conditions.
If it was SQL, I want…

Uziel Davidi
- 103
- 10