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...
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
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...
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...
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...
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":
...
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...
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:..
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...
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...
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...
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...
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...
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...
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 ...
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...
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)
{
...