本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EdmMember类的典型用法代码示例。如果您正苦于以下问题:C# EdmMember类的具体用法?C# EdmMember怎么用?C# EdmMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmMember类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了EdmMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetSetterExpression
// effects: try to find setter expression for the given member
// requires: command tree must be an insert or update tree (since other DML trees hnabve
private static bool TryGetSetterExpression(
DbModificationCommandTree tree, EdmMember member, ModificationOperator op, out DbSetClause setter)
{
Debug.Assert(op == ModificationOperator.Insert || op == ModificationOperator.Update, "only inserts and updates have setters");
IEnumerable<DbModificationClause> clauses;
if (ModificationOperator.Insert == op)
{
clauses = ((DbInsertCommandTree)tree).SetClauses;
}
else
{
clauses = ((DbUpdateCommandTree)tree).SetClauses;
}
foreach (DbSetClause setClause in clauses)
{
// check if this is the correct setter
if (((DbPropertyExpression)setClause.Property).Property.EdmEquals(member))
{
setter = setClause;
return true;
}
}
// no match found
setter = null;
return false;
}
示例2: TryGetMember
// <summary>
// Given the type in the target space and the member name in the source space,
// get the corresponding member in the target space
// For e.g. consider a Conceptual Type 'Abc' with a member 'Def' and a CLR type
// 'XAbc' with a member 'YDef'. If one has a reference to Abc one can
// invoke GetMember(Abc,"YDef") to retrieve the member metadata for Def
// </summary>
// <param name="type"> The type in the target perspective </param>
// <param name="memberName"> the name of the member in the source perspective </param>
// <param name="ignoreCase"> Whether to do case-sensitive member look up or not </param>
// <param name="outMember"> returns the member in target space, if a match is found </param>
internal virtual bool TryGetMember(StructuralType type, String memberName, bool ignoreCase, out EdmMember outMember)
{
DebugCheck.NotNull(type);
Check.NotEmpty(memberName, "memberName");
outMember = null;
return type.Members.TryGetValue(memberName, ignoreCase, out outMember);
}
示例3: LinqToEntitiesTypeDescriptor
/// <summary>
/// Constructor taking a metadata context, an structural type, and a parent custom type descriptor
/// </summary>
/// <param name="typeDescriptionContext">The <see cref="LinqToEntitiesTypeDescriptionContext"/> context.</param>
/// <param name="edmType">The <see cref="StructuralType"/> type (can be an entity or complex type).</param>
/// <param name="parent">The parent custom type descriptor.</param>
public LinqToEntitiesTypeDescriptor(LinqToEntitiesTypeDescriptionContext typeDescriptionContext, StructuralType edmType, ICustomTypeDescriptor parent)
: base(parent)
{
_typeDescriptionContext = typeDescriptionContext;
_edmType = edmType;
EdmMember[] timestampMembers = _edmType.Members.Where(p => ObjectContextUtilities.IsConcurrencyTimestamp(p)).ToArray();
if (timestampMembers.Length == 1)
{
_timestampMember = timestampMembers[0];
}
if (edmType.BuiltInTypeKind == BuiltInTypeKind.EntityType)
{
// if any FK member of any association is also part of the primary key, then the key cannot be marked
// Editable(false)
EntityType entityType = (EntityType)edmType;
_foreignKeyMembers = new HashSet<EdmMember>(entityType.NavigationProperties.SelectMany(p => p.GetDependentProperties()));
foreach (EdmProperty foreignKeyMember in _foreignKeyMembers)
{
if (entityType.KeyMembers.Contains(foreignKeyMember))
{
_keyIsEditable = true;
break;
}
}
}
}
示例4: EntityProxyMemberInfo
internal EntityProxyMemberInfo(EdmMember member, int propertyIndex)
{
DebugCheck.NotNull(member);
Debug.Assert(propertyIndex > -1, "propertyIndex must be non-negative");
_member = member;
_propertyIndex = propertyIndex;
}
示例5: EntityProxyMemberInfo
internal EntityProxyMemberInfo(EdmMember member, int propertyIndex)
{
Debug.Assert(member != null, "member must be non-null");
Debug.Assert(propertyIndex > -1, "propertyIndex must be non-negative");
_member = member;
_propertyIndex = propertyIndex;
}
示例6: FieldMetadata
/// <summary>
/// Initializes a new <see cref="T:System.Data.Entity.Core.Common.FieldMetadata" /> object with the specified ordinal value and field type.
/// </summary>
/// <param name="ordinal">An integer specified the location of the metadata.</param>
/// <param name="fieldType">The field type.</param>
public FieldMetadata(int ordinal, EdmMember fieldType)
{
if (ordinal < 0)
{
throw new ArgumentOutOfRangeException("ordinal");
}
Check.NotNull(fieldType, "fieldType");
_fieldType = fieldType;
_ordinal = ordinal;
}
示例7: FieldMetadata
/// <summary>
/// Used to construct a field metadata object relating a column ordinal and an ImemberMetadata.
/// </summary>
/// <param name="ordinal"> Column oridnal </param>
/// <param name="fieldType"> Metadata member </param>
public FieldMetadata(int ordinal, EdmMember fieldType)
{
if (ordinal < 0)
{
throw new ArgumentOutOfRangeException("ordinal");
}
if (null == fieldType)
{
throw new ArgumentNullException("fieldType");
}
_fieldType = fieldType;
_ordinal = ordinal;
}
示例8: TryGetMember
/// <summary>
/// Given the type in the target space and the member name in the source space,
/// get the corresponding member in the target space
/// For e.g. consider a Conceptual Type Foo with a member bar and a CLR type
/// XFoo with a member YBar. If one has a reference to Foo one can
/// invoke GetMember(Foo,"YBar") to retrieve the member metadata for bar
/// </summary>
/// <param name="type"> The type in the target perspective </param>
/// <param name="memberName"> the name of the member in the source perspective </param>
/// <param name="ignoreCase"> true for case-insensitive lookup </param>
/// <param name="outMember"> returns the edmMember if a match is found </param>
/// <returns> true if a match is found, otherwise false </returns>
internal override bool TryGetMember(StructuralType type, String memberName, bool ignoreCase, out EdmMember outMember)
{
outMember = null;
Map map = null;
if (MetadataWorkspace.TryGetMap(type, DataSpace.OCSpace, out map))
{
var objectTypeMap = map as ObjectTypeMapping;
if (objectTypeMap != null)
{
var objPropertyMapping = objectTypeMap.GetMemberMapForClrMember(memberName, ignoreCase);
if (null != objPropertyMapping)
{
outMember = objPropertyMapping.EdmMember;
return true;
}
}
}
return false;
}
示例9: Add
// <summary>
// Add an entry that the given property of the given var is a computation represented
// by the computationTemplate over the var represented by the given groupAggregateVarInfo
// </summary>
internal void Add(
Var var, GroupAggregateVarInfo groupAggregateVarInfo, Node computationTemplate, bool isUnnested, EdmMember property)
{
if (property == null)
{
Add(var, groupAggregateVarInfo, computationTemplate, isUnnested);
return;
}
if (_groupAggregateVarRelatedVarPropertyToInfo == null)
{
_groupAggregateVarRelatedVarPropertyToInfo = new Dictionary<Var, Dictionary<EdmMember, GroupAggregateVarRefInfo>>();
}
Dictionary<EdmMember, GroupAggregateVarRefInfo> varPropertyDictionary;
if (!_groupAggregateVarRelatedVarPropertyToInfo.TryGetValue(var, out varPropertyDictionary))
{
varPropertyDictionary = new Dictionary<EdmMember, GroupAggregateVarRefInfo>();
_groupAggregateVarRelatedVarPropertyToInfo.Add(var, varPropertyDictionary);
}
varPropertyDictionary.Add(property, new GroupAggregateVarRefInfo(groupAggregateVarInfo, computationTemplate, isUnnested));
// Note: The following line is not necessary with the current usage pattern, this method is
// never called with a new groupAggregateVarInfo thus it is a no-op.
_groupAggregateVarInfos.Add(groupAggregateVarInfo);
}
示例10: GetObjectMember
/// <summary>
/// Tries and get the mapping ospace member for the given edmMember and the ospace type
/// </summary>
/// <param name="edmMember"></param>
/// <param name="objectType"></param>
/// <returns></returns
private static EdmMember GetObjectMember(EdmMember edmMember, StructuralType objectType)
{
// Assuming that we will have a single member in O-space for a member in C space
EdmMember objectMember;
if (!objectType.Members.TryGetValue(edmMember.Name, false /*ignoreCase*/, out objectMember))
{
throw new MappingException(
Strings.Mapping_Default_OCMapping_Clr_Member(
edmMember.Name, edmMember.DeclaringType.FullName, objectType.FullName));
}
return objectMember;
}
示例11: GetSlotIndex
/// <summary>
/// Returns the slot index for the following member path: <paramref name="member" />.<paramref name="child" />, e.g., CPerson1.pid
/// </summary>
private int GetSlotIndex(MemberPath member, EdmMember child)
{
var fullMember = new MemberPath(member, child);
var index = m_projectedSlotMap.IndexOf(fullMember);
Debug.Assert(index != -1, "Couldn't locate " + fullMember + " in m_projectedSlotMap");
return index;
}
示例12: EmitMember
public bool EmitMember(
TypeBuilder typeBuilder, EdmMember member, PropertyBuilder propertyBuilder, PropertyInfo baseProperty,
BaseProxyImplementor baseImplementor)
{
if (_members.Contains(member))
{
var baseGetter = baseProperty.GetGetMethod(true);
const MethodAttributes getterAttributes =
MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.Virtual;
var getterAccess = baseGetter.Attributes & MethodAttributes.MemberAccessMask;
// Define field to store interceptor Func
// Signature of interceptor Func delegate is as follows:
//
// bool intercept(ProxyType proxy, PropertyType propertyValue)
//
// where
// PropertyType is the type of the Property, such as ICollection<Customer>,
// ProxyType is the type of the proxy object,
// propertyValue is the value returned from the proxied type's property getter.
var interceptorType = typeof(Func<,,>).MakeGenericType(typeBuilder, baseProperty.PropertyType, typeof(bool));
var interceptorInvoke = TypeBuilder.GetMethod(interceptorType, typeof(Func<,,>).GetMethod("Invoke"));
var interceptorField = typeBuilder.DefineField(
GetInterceptorFieldName(baseProperty.Name), interceptorType, FieldAttributes.Private | FieldAttributes.Static);
// Define a property getter override in the proxy type
var getterBuilder = typeBuilder.DefineMethod(
"get_" + baseProperty.Name, getterAccess | getterAttributes, baseProperty.PropertyType, Type.EmptyTypes);
var generator = getterBuilder.GetILGenerator();
// Emit instructions for the following call:
// T value = base.SomeProperty;
// if(this._interceptorForSomeProperty(this, value))
// { return value; }
// return base.SomeProperty;
// where _interceptorForSomeProperty represents the interceptor Func field.
var lableTrue = generator.DefineLabel();
generator.DeclareLocal(baseProperty.PropertyType); // T value
generator.Emit(OpCodes.Ldarg_0); // call base.SomeProperty
generator.Emit(OpCodes.Call, baseGetter); // call to base property getter
generator.Emit(OpCodes.Stloc_0); // value = result
generator.Emit(OpCodes.Ldarg_0); // load this
generator.Emit(OpCodes.Ldfld, interceptorField); // load this._interceptor
generator.Emit(OpCodes.Ldarg_0); // load this
generator.Emit(OpCodes.Ldloc_0); // load value
generator.Emit(OpCodes.Callvirt, interceptorInvoke); // call to interceptor delegate with (this, value)
generator.Emit(OpCodes.Brtrue_S, lableTrue); // if true, just return
generator.Emit(OpCodes.Ldarg_0); // else, call the base propertty getter again
generator.Emit(OpCodes.Call, baseGetter); // call to base property getter
generator.Emit(OpCodes.Ret);
generator.MarkLabel(lableTrue);
generator.Emit(OpCodes.Ldloc_0);
generator.Emit(OpCodes.Ret);
propertyBuilder.SetGetMethod(getterBuilder);
baseImplementor.AddBasePropertyGetter(baseProperty);
return true;
}
return false;
}
示例13: CanProxyMember
public bool CanProxyMember(EdmMember member)
{
return _members.Contains(member);
}
示例14: GetVariableType
internal static string GetVariableType(SqlGenerator sqlGenerator, EdmMember column)
{
DebugCheck.NotNull(sqlGenerator);
DebugCheck.NotNull(column);
var columnType
= SqlGenerator.GenerateSqlForStoreType(sqlGenerator.SqlVersion, column.TypeUsage);
if (columnType == "rowversion"
|| columnType == "timestamp")
{
// rowversion and timestamp are intrinsically read-only. use binary to gather server generated
// values for these types.
columnType = "binary(8)";
}
return columnType;
}
示例15: GetEpmInformationFromProperty
internal static IEnumerable<EpmPropertyInformation> GetEpmInformationFromProperty(EdmMember edmMember)
{
return GetEpmPropertyInformation(edmMember, edmMember.DeclaringType.Name, edmMember.Name);
}