public bool TryConvertEdmType(PrimitiveType primitiveType, FacetInfo facets, out Type result) { result = null; if (string.Equals("binary", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase) || string.Equals("image", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase)) { result = typeof(NMemory.Data.Binary); return(true); } if (string.Equals("rowversion", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase) || string.Equals("timestamp", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase)) { result = typeof(NMemory.Data.Timestamp); return(true); } if (string.Equals("geometry", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase)) { result = typeof(NMemory.Spatial.DbGeometry); return(true); } if (string.Equals("geography", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase)) { result = typeof(NMemory.Spatial.DbGeography); return(true); } return(false); }
public EntityPropertyInfo( string name, Type type, FacetInfo facets, List<IndexInfo> indexes) { this.name = name; this.type = type; this.facets = facets; this.indexes = indexes.ToList().AsReadOnly(); }
private Type CreateRowType(RowType rowType, FacetInfo facets) { Dictionary <string, Type> members = new Dictionary <string, Type>(); foreach (EdmMember member in rowType.Members) { members.Add(member.GetColumnName(), this.Convert(member.TypeUsage)); } Type result = DataRowFactory.Create(members); return(result); }
public FacetInfo GetTypeFacets(TypeUsage type) { FacetInfo facets = new FacetInfo(); Facet facet = null; if (type.Facets.TryGetValue("Nullable", false, out facet)) { facets.Nullable = (bool)facet.Value == true; } if (type.Facets.TryGetValue("FixedLength", false, out facet)) { if (!facet.IsUnbounded && facet.Value != null) { facets.FixedLength = (bool)facet.Value == true; } } if (type.Facets.TryGetValue("StoreGeneratedPattern", false, out facet)) { switch ((StoreGeneratedPattern)facet.Value) { case StoreGeneratedPattern.Computed: facets.Computed = true; break; case StoreGeneratedPattern.Identity: facets.Identity = true; break; } } if (type.Facets.TryGetValue("MaxLength", false, out facet)) { if (facet.IsUnbounded) { facets.LimitedLength = false; } else if (facet.Value != null) { facets.MaxLength = (int)facet.Value; facets.LimitedLength = true; } } return(facets); }
public FacetInfo GetTypeFacets(TypeUsage type) { FacetInfo facets = new FacetInfo(); Facet facet = null; if (type.Facets.TryGetValue("Nullable", false, out facet)) { facets.Nullable = (bool)facet.Value == true; } if (type.Facets.TryGetValue("FixedLength", false, out facet)) { if (!facet.IsUnbounded && facet.Value != null) { facets.FixedLength = (bool)facet.Value == true; } } if (type.Facets.TryGetValue("StoreGeneratedPattern", false, out facet)) { switch ((StoreGeneratedPattern)facet.Value) { case StoreGeneratedPattern.Computed: facets.Computed = true; break; case StoreGeneratedPattern.Identity: facets.Identity = true; break; } } if (type.Facets.TryGetValue("MaxLength", false, out facet)) { if (facet.IsUnbounded) { facets.LimitedLength = false; } else if (facet.Value != null) { facets.MaxLength = (int)facet.Value; facets.LimitedLength = true; } } return facets; }
private Type ConvertWithFacets(TypeUsage type, FacetInfo facets) { if (type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType) { return(this.CreatePrimitiveType(type.EdmType as PrimitiveType, facets)); } else if (type.EdmType.BuiltInTypeKind == BuiltInTypeKind.RowType) { return(this.CreateRowType(type.EdmType as RowType, facets)); } else if (type.EdmType.BuiltInTypeKind == BuiltInTypeKind.CollectionType) { return(this.CreateCollectionType(type.EdmType as CollectionType, facets)); } throw new NotSupportedException(); }
private Type CreatePrimitiveType(PrimitiveType primitiveType, FacetInfo facets) { Type result = null; if (this.converter.TryConvertEdmType(primitiveType, facets, out result)) { return(result); } result = primitiveType.ClrEquivalentType; if (facets.Nullable && result.IsValueType) { result = typeof(Nullable <>).MakeGenericType(result); } return(result); }
public bool TryConvertEdmType(PrimitiveType primitiveType, FacetInfo facets, out Type result) { result = null; if (string.Equals("binary", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase)) { result = typeof(NMemory.Data.Binary); return true; } if (string.Equals("rowversion", primitiveType.Name, StringComparison.InvariantCultureIgnoreCase)) { result = typeof(NMemory.Data.Timestamp); return true; } return false; }
public Type ConvertNotNull(TypeUsage type) { FacetInfo facets = new FacetInfo(); return this.ConvertWithFacets(type, facets); }
private Type CreateCollectionType(CollectionType collectionType, FacetInfo facets) { Type elementType = this.ConvertWithFacets(collectionType.TypeUsage, facets); return elementType.MakeArrayType(); }
private Type CreateRowType(RowType rowType, FacetInfo facets) { Dictionary<string, Type> members = new Dictionary<string, Type>(); foreach (EdmMember member in rowType.Members) { members.Add(member.GetColumnName(), this.Convert(member.TypeUsage)); } Type result = DataRowFactory.Create(members); return result; }
private Type CreatePrimitiveType(PrimitiveType primitiveType, FacetInfo facets) { Type result = null; if (this.converter.TryConvertEdmType(primitiveType, facets, out result)) { return result; } result = primitiveType.ClrEquivalentType; if (facets.Nullable && result.IsValueType) { result = typeof(Nullable<>).MakeGenericType(result); } return result; }
private Type ConvertWithFacets(TypeUsage type, FacetInfo facets) { if (type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType) { return this.CreatePrimitiveType(type.EdmType as PrimitiveType, facets); } else if (type.EdmType.BuiltInTypeKind == BuiltInTypeKind.RowType) { return this.CreateRowType(type.EdmType as RowType, facets); } else if (type.EdmType.BuiltInTypeKind == BuiltInTypeKind.CollectionType) { return this.CreateCollectionType(type.EdmType as CollectionType, facets); } throw new NotSupportedException(); }
public Type ConvertNotNull(TypeUsage type) { FacetInfo facets = new FacetInfo(); return(this.ConvertWithFacets(type, facets)); }
public Type Convert(TypeUsage type) { FacetInfo facets = this.GetTypeFacets(type); return(this.ConvertWithFacets(type, facets)); }
private Type CreateCollectionType(CollectionType collectionType, FacetInfo facets) { Type elementType = this.ConvertWithFacets(collectionType.TypeUsage, facets); return(elementType.MakeArrayType()); }