c# - Instantiating DbEntityEntry<T> with Reflection -
After
I am trying to create a DbEntityEntry & lt; Through reflections for testing purposes
T & gt; Its constructor is internal, but I want to call it and pass it in one unit:
Public DbEntityEntry & lt; T & gt; Entry & lt; T & gt; (T unit) where T: class {type construction type = type (DbEntityEntry ); Binding Flags = Binding Flags Nonpolic | BindingFlags.Instance; Object X = Activator Create (creation type, flags, blank, new object [] {entity}, blank);
I am:
Type 'System.Data.Entity.Infrastructure.DbEntityEntry`1 Creator [[System.Object, mscorlib, version = 4.0 .0.0, Culture = Neutral, PublicKeyToken = b77a5c561934e089]] 'Not Found
is the source for the creator.
Internal DbEntityEntry (InternalEntityEntry internalEntityEntry) {DebugCheck.NotNull (Internal Interval Entry); _internalEntityEntry = internalEntityEntry; }
Any way to create an example?
UPDATE:
The original code was actually picked up from Mark Gravel's last reply, but since this post is a candidate to be close, I suggest another Using Gravell's answer will provide a look:
type [argTypes = new type [] {typeof (t)}; Object [] argValues = new object [] {unit}; Binding Flags = Binding Flags Nonpolic | BindingFlags.Instance; ConstructorInfo ctor = typeof (Getty Images) Object obj = ctor.invoke (argValues);
ctor
is incomplete, so the manufacturer could not be found again.
Ask for a way to institute a third party type with reflection instead of asking how your code changes It may be tested and hacks are not required. If you post DbEntityEntry
ctor, you will see that it takes an internal entry entry
- you have to instantify another internal class (with reflection) . So you will create a lot of internal things yourself, even if you do not have intimate knowledge about actually working together, and if EF is to separate these items then your tests can be useless because they are Also, the program will not work, apart from this it is the internal stuff because it can turn into the next version and your test can not work properly with the new version Land. There are not enough details in your post to be able to give better advice. Note that you can create DbEntityEntry
using the public API with the method.
Comments
Post a Comment