entity-framework

Many-to-many sorting in Entity Framework

My application has an Entity Framework model containing a many-to-many relationship like the following: ProductGroup: Scalar: Id, Name Navigation: ProductGroupProduct Product: Scalar: Id, Sku, Description, etc. Navigation: ProductGroupProduct ProductGroupProduct: Scalar: ProductGroupId, ProductId, Position Nav...

Resolving associated objects in SL4 RIA

Having created a standard Silverlight Business Application in VS2010 and set up a model from a SQL Server database, I have various entities and associations, among which AssetGroup and Asset are in a 1:m relationship. Allegedly I can use dot notation to get the associated AssetGroup out of an asset instance. Through the modern miracles ...

Why doesn't this join work with Entity Framework v4?

I use Entity Framework v4 (code-only). If I do var result = from person in context.People.Include("Cars") select new { person, person.Houses.Count, bar, foo, etc }; then result.First().Cars is null. If I do this way, it works, but I need Houses.Count: var result = from person in context.People.Include("Cars") ...

Using Entity Framework, how do I reflect a many to many relationship and add entites that exist to a new entity being created?

I'm new to Entity Framework and am trying to figure things out. I have a database created that's not very complicated. There's about 7 tables and 3 of those are mapping tables to associate one table record w/ another. The example I'm using here is this: Table User UserId UserName Table Role RoleId RoleName Table: UserRole UserI...

Editing and Updating Entity Framework entity in ASP .NET MVC

Hello, I have an entityframework entity called "ABC" (attributes ID and Title). On update record view, I have added the ID as hidden field and title is the text box. Controller looks like something: public ActionResult UpdateAction( ABC obj ) I get everything fine and fair in obj - i.e., the title, and the ID. Now to update the re...

Malicious input in ASP.NET MVC

Hello, I have ASP.NET MVC 1.0 and Entity Framework v1 application. By default, content submitted by user is validated for malicious input. (See here). HTML encoding user submitted data, prevents JavaScript injection attacks. Entity Framework internally uses parameterized SQL which will stop sql injection. Is this sufficient ? What e...

How to write simple Where Clause for dynamic filtering in linq when we use groups in join

I have simple search page i want to filter the results. var TransactionStats = from trans in context.ProductTransactionSet.Include("SPL") select new { trans.InvoiceNo, ProductGroup = from tranline in trans.ProductTransactionLines group tranline by tranline.ProductTransaction.TransactionID ...

MySQL Connector for .NET - Is it REALLY mature?

After spending a miserable month with MySQL/.NET/EntityFramework, my findings: Support for Entity Framework is VERY primitive, please use it for student-subjects type of database. Kindly do not consider it using for serious development as they ARE STILL unable to sort out VERY BASIC things like: it DOES NOT support unsigned stuff it D...

PHP Inertia framework i didnt find much information from the web

Anyone has any idea about PHP Inertia framework? how do u evaluate it?Google didnt help me to find out it's manuel. ...

Handling invalid values with ModelBinder in ASP.NET MVC 1.0

Hey all. First of all some context: I have a form, where I post back some objects that are automatically materialized into objects by MVCs built-in ModelBinder: <input type="hidden" name="myobj[0].Id" /> <input type="text" name="myobj[0].Hours" /> <input type="hidden" name="myobj[1].Id" /> <input type="text" name="myobj[1].Hours" /> ...

Static and Generic working together .NET

Hi, I have this code: public class EntityMapper<T> where T : IMappingStrategy, new() { private static T currentStrategy; public static T CurrentStrategy { get { if (currentStrategy == null) currentStrategy = new T(); return currentStrategy; } } } Th...

EF4 - Changes not being captured between sessions

I'm trying to test detaching an entity from one context, making modifications to it, creating a new context, attaching it, and having the changes made between sessions persist. I don't seem to be able to get this working appropriately. I've tried calling DetectChanges as well as ApplyCurrentValues w/ no success. Below is what I've got so...

Order By on a modified Entity Framework object

I'm getting an Entity Framework object collection from my Products table called oProducts. I am looping through the collection and setting the Quantity field from a separate function. Before I write out a display of the objects in HTML, I want to sort them by the Quantity. So, I am using LINQ to create a new collection and try to orde...

Which DAL choice should I use?

I'm working on a little side project. I've got a large SQL query expression, 30+ lines, that I wish to use in my project. This app needs to provide read-only access to the database through these queries. There are so many data layer choices. nHibernate, Entity Framework, LINQ to SQL, Datasets, Castle ActiveRecord... others I can't na...

Using NOLOCK Hint in EF4?

We're evaluating EF4 and my DBA says we must use the NOLOCK hint in all our SELECT statements. So I'm looking into how to make this happen when using EF4. I've read the different ideas on how to make this happen in EF4, but all seem like a work around and not sanctioned by Microsoft or EF4. What is the "official Microsoft" response to...

Unique Keys not recognized by Entity Framework

I have two tables, Reports and Visualizations. Reports has a field, VisualizationID, which points to Visualization's field of the same name via a foreign key. It also has a unique key declared on the field. VisualizationID is not nullable. This means the relationship has to be 0..1 to 1, because every Reports record must have a unique, n...

Entity Framework - Correct way to check for single records before using them

To get a LIST of records I normally do something along the lines of: var efCompany = from a in _dbRiv.Company where a.CompanyId == companyFeedInfo.CompanyId select a; To get a single record, when I know I am using the PK to retrieve it, I use something like: var efCompany = (from a in _dbRiv.Company where a.CompanyId == companyFeedIn...

Possible weaknesses regarding using reflection in a business application

Hi, Experimenting using different approaches and reducing code maintenance I have ended up using reflection to create new forms in my MDI application. The reason for this 'solution' is to provide a central place to setup new forms, implement security checks and possible future needs. I currently have a static Activator class that is i...

How do I set a Type TSomething at run time in C#?

I am writting a function that takes a parameter and that parameter requires a Type of TEntity. I want to be able to pass it a specific Type during runtime but I am having trouble getting it to compile: public LoadOperation LoadQuery(EntityQuery<???> query) { LoadOperation loadOperation = DomainContext.Load(query,Load...

LINQ expression return null

I have the following query in LINQ. "Symbol" doesn't exist, and the query is null, but I got an error, of casting and the program crashes. decimal x = from cie in m_entities.Cie where cie.symbol.Equals(Symbol) select cie.cie_id; Or can I have a null in x? ...