zzz projects Entity Framework 6 EF 6
Home EF Core Articles Knowledge Base Online Examples
  • Home
  • EF Core
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework 6 - Knowledge Base (KB)

17 results in tag: reflection

Reflection is used to dynamically cast a property to its real type.

I need to cast a property to its actual type dynamically. How do I/Can I do this using reflection?...To explain the real scenario that I am working on a bit. I am trying to call the "First" extension method on an Entity Framework property. The specific pr...
c# entity-framework reflection
asked by Keith K

Is there a method to acquire the name of the entity id-field using reflection or something?

I am trying to get the ID field name (property name) of an entity, is it possible?...User user= new User(); //User is an Entity...string idField = ??????? //user.UserId
.net c# entity-framework propertyinfo reflection
asked by Shimmy

How can I generate an expression tree for a query by reflecting over T?

I'm trying to build a generic class to work with entities from EF. This class talks to repositories, but it's this class that creates the expressions sent to the repositories. Anyway, I'm just trying to implement one virtual method that will act as a base...
c# entity-framework expression-trees linq reflection
asked by Gup3rSuR4c

EntityFramework How can I get an item by ID?

Is it possible with Generics to get an object from my EntityFramework without knowing the type?...I'm thinking of something along the lines of:...public T GetObjectByID<T>(int id) { return (from i in myDatabase.T where i.ID == id select i); } ...Is tha...
asp.net c# entity-framework linq reflection
asked by James P. Wright

How to obtain attributes declared on incomplete classes using.NET reflection

I use the .NET Entity Framework. I want to copy properties from one EntityObject to another. But System.Type.GetProperties() does not seem to return the properties defined on the partial class....Code:...In XXX.edmx/ XXX.Designer.cs generated by Visual St...
.net c# entity-framework linq reflection
asked by Bùi Việt Thành

Entity framework - get entity by name

I have the following code (example):...public dynamic GetData(string name) { using(var ctx = GetObjectContext()) { switch (name) { case "entity1": return ctx.entity1.ToList(); case "entity2": ...
c# entity-framework reflection
asked by user1209216

Dynamically query entities from Entity Framework for association to primary Entity

I know the title wasn't the greatest, but here is what I actually want to accomplish....I have a details view that represents Entity1 and its associations. I am capturing the property names and values in a key/value pair. I am currently using reflection t...
c# dynamic-queries entity-framework expression-trees reflection
asked by m4chine

Create a lambda expression with a new anonymous type at runtime

I want to invoke a method that expects a parameter like this:...Expression<Func<sometype, 'a>> expr ...I need to construct this parameter at runtime, because I won't know what the anonymous type will look like before; it could have any amount of fields:..
anonymous-types c# entity-framework expression-trees reflection
asked by EPLKleijntjens

Change DbContext connection at run-time

I have 3 DBs that I want to work with: A,B and C. each one have the same tables (for example: users, products)....I want to let the user decide (on run-time) which DB he wants to work with. So... I used EF5 and created 3 edbx files which created the follo...
c# database entity entity-framework reflection
asked by user3017270

EntityFramework 6 How to get identity-field with reflection?

I have a generic method with type parameter T, where T is the type of entity in EF model. I need to get the name of identifying field in this type. I saw this article: ...Is there a way to get entity id-field's name by reflection or whatever?... But I can...
c# entity-framework entity-framework-6 reflection
asked by Jonik

How do I select correct DbSet in DbContext based on table name

Say I have a DbContext with the following DbSets...class Amimals : DbContext { public DbSet<Dog> Dogs { get; set; } public DbSet<Cat> Cats { get; set; } } ...Inside of each EntityTypeConfiguration I am defining the table for each DbSet like...clas...
c# entity-framework linq reflection
asked by DobleA

Dynamic table name in linq

I'm trying to execute some ...LINQ... commands using a dynamic table name. For example, instead of:...var o = (from x in context.users select x); ...I want to use something like:...var o = (from x in getTableObjectByName("users", context) select x); ...Mo...
c# entity-framework linq reflection
asked by Russell Uhl

How to cast DbSet<T> to List<T>

Given the following simplified Entity Framework 6 context, I am trying to populate a List with the entities but having problems with how to cast (I believe) via reflection....public class FooContext : DbContext { public virtual IDbSet<FooClass> Foo { g...
c# casting entity-framework-6 reflection
asked by Kyle

Switching from Reflection to Expression trees

Since reflection on a row by row basis is rather expensive, I've been looking for a faster alternative to build and insert entities. I did some research ...research ... on the subject and also found some performance ...comparisons... which seem to indicat...
c# entity-framework expression-trees parallel.foreach reflection
asked by jdm5310

Entity Framework model creating with reflection

I'm trying to create a model with classes derived in different assemblies. When I do this without reflection, evething is OK: migration is being created successfully and database is being updated....protected override void OnModelCreating(DbModelBuilder ...
c# ef-code-first entity-framework entity-framework-6 reflection
asked by Михаил Бабушкин

Auto Column Mapping Using Reflection and expression

is that possible to automate these mappings with reflection?...i have a simple column mapping :...var columnsMap = new Dictionary<string, Expression<Func<Industry, object>>> { ["id"] = v => v.Id, ["name"] = v => v.Name, ["isActive"] = v => v.I...
.net-core c# entity-framework expression-trees reflection
asked by AliReza

EntityType' is a variable but is used like a type when use the Reflection

i need to register all entity in ...DbContext... ....i create a ...extention... for register automatic all Entity with ...Reflection... :... public static void RegisterAllEntity<BaseType>(this DbModelBuilder builder, params Assembly[] assmblies) { ...
c# entity-framework-6 reflection
asked by mr-dortaj

Page 1 of 1
  • 1

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Save your entities 20× faster with EF Extensions
SaveChanges vs BulkSaveChanges

EF Extensions
Try for free now
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!