I have a Windows forms DataGridView with a combobox column. The combo box column is bound to a data source that is populated from a Linq to Entities query. I would like users to be able to select "Nothing" in the combo box (assign a value of NULL to the underlying data source).
How can I accomplish this?
...
I have a detached entity that has a navigation property as such:
public class ClassA
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<ClassB> ClassB
{
get
{
if (_classB == null)
{
var newCollection = new FixupCollection<ClassB>();
...
The default order of ObjectSet is by identity. Is there any attribute I can use in mapping to specify the custom order? I don't want introduce any property that would order entities, instead of "EntitiesByMyOrder" property i want the certain order as default order from mappings.
thanks in advance.
...
I've been using the entities framework with ASP.NET MVC and I'm looking for an easy and fast way to drop all of the information in the database. It takes quite a while to delete all of the information from the entities object and then save the changes to the database (probably because there are a lot of many-to-many relationships) and I ...
I'm getting this error:
Only parameterless constructors and initializers are supported in LINQ to Entities.
When trying to run this code (found this code here and made test database to play around with):
XElement xml = new XElement("contacts",
from c in db.Contacts
orderby c.ContactId
...
I have a service which will add , update and delete a patient entity .
I made the patient entity is selftracking entity .
But only for delete i need to call 'Attach' the entity before deleting , why not attach required for add and update .
What is the logic behind attaching only for delete ( I have cascading property = true)
publi...
Just a quick pre-emptive question before we start to seriously investigate using Lucene.
Currently building a C# WPF application, using MVVM and Microsoft Entity framework. My lead has brought up the point that this might represent a problem with us not being able to let Lucene directly access the database, and therefore there might be ...
Hi -
I'm serializing an entity from an EF 4 context which has a GUID primary key. Works fine, everything is serialized into an XML file which is transmitted to another computer. There I need to get the object exactly as it is into the database on this host. And this is where things don't work anymore.
When I deserialize the entity and...
when i create my entity data model i have a situation in the DB like this :
TableFirst : [Id,IdTableSecond,IdTableSecondAgain];TableSecond[Id]
Created data model is: TableFirst.TableSecond and TableFirst.TableSecond1
Question is: Every time when i create my entity TableFirst.TableSecond will have same relation in behind (IdTable...
I have a asp.net mvc 2 on .net 4 with code first entity framework data access.
When I deploy to one server it works beautifully, no prizes for guessing it doesnt work on the other...the message however I cannot understand
Attempt by method 'System.Data.Entity.ModelConfiguration.Internal.Configuration.CodeFirstCachedMetadataWorkspace.G...
I'm trying to stub a call to db. The basic idea is for a line of code like this:
Person person = (from p in this.Entities.FindPerson("Smith") select p).FirstOrDefault();
to return an object the way I want it without going of to db. FindPerson(string) represents a stored proc (just in case).
I tried to overwrite FindPerson but I need ...
I have 2 tables Jobs and Schedule
Jobs
JobId - int,PK, Identity
ScheduleId - int, FK
Title - varchar
Description - varchar
Schedules
ScheduleId - int,PK, Identity
Name - varchar
There is a relationship one to many with cascade on delete.
When I create Entity model, the generated Jobs model removes the ScheduleId field.
Th...
Okay, here's the scenario. I have 3 tables. One called aspnet_Users one called Categories and a linking table called User_Categories. aspnet_Users and Categories both have primary keys (UserId and ID respectively). The linking table has only two columns: CategoryID and UserId, and there are foreign key relationships setup for each co...
Newbee here: Thinking on using this: http://www.albahari.com/nutshell/linqkit.aspx
I am creating an asp .net web app/c#/EF4, where users can perform search from a set of textboxes.
Here are the basic rules.
User can search on any number of fields. (no fields are required)
Each field has an option dropdown to choose "equal" "contains"...
Is there a way to map a collection/dictionary of primitive types in Entity Framework. I would like to have:
public class Abc
{
public virtual long Id {get;set;}
public virtual ... some properties
public virtual IList<float> Numbers;
// or even:
public virtual IDictionary<DateTime,decimal> MoreNumbers; ...
I'm using .NET 4 and the Entity Framework to construct a simple query. Here's the C# code:
return Context.Files.Where(f => f.FileHash != 40)
.OrderByDescending(f => f.Created)
.Take(5);
When I trace the query using ObjectQuery.ToTraceString(), I find the following subquery:
SELECT TOP (5)
[P...
I am having a very tough time with this one. I have a Navigation property called Attachment that is part of an entity called ContentChannel. ContentChannel is a many to one relationship with KioskType.
In my domain service extension class, I have the following query:
public IQueryable<ContentChannel> GetContentChannelFromKioskType( l...
Is it possible for a project using entirely LinqToSQL or Entity Framewok to suffer from SQL Injection.
I think that probably not because the SQL that the ORM generates should be sql-injection free. But I'm not sure.
...
Hi. I'm an old-school database programmer. And all my life i've working with database via DAL and stored procedures. Now i got a requirement to use Entity Framework.
Could you tell me your expirience and architecture best practicies how to work with it ?
As I know ORM was made for programmers who don't know SQL expression. And this is ...
I've created a BLL which queries Entity Framework context. EDML file is in the same BLL assembly. It accepts EF entities as parameters from presentation layer and returns EF entities as results. To accomplish this I kept entities public so presentation layer can create them like DLL.TablName newRecord = new DLL.TableName() etc. The probl...