internal static DBPropSet CreateProperty(Guid propertySet, int propertyId, bool required, object value) { ItagDBPROP dbprop = OleDbStructHelpers.CreateTagDbProp(propertyId, required, value); DBPropSet propertyset = new DBPropSet(1); propertyset.SetPropertySet(0, propertySet, new ItagDBPROP[1] { dbprop }); return(propertyset); }
internal ItagDBPROP[] GetPropertySet(int index, out Guid propertyset) { if ((index < 0) || (PropertySetCount <= index)) { if (lastErrorFromProvider != null) { // add extra error information for CSS/stress troubleshooting. // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1. throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider); } else { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } } tagDBPROPSET propset = new tagDBPROPSET(); ItagDBPROP[] properties = null; bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { DangerousAddRef(ref mustRelease); IntPtr propertySetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET); Marshal.PtrToStructure(propertySetPtr, propset); propertyset = propset.guidPropertySet; properties = new ItagDBPROP[propset.cProperties]; for (int i = 0; i < properties.Length; ++i) { properties[i] = OleDbStructHelpers.CreateTagDbProp(); IntPtr ptr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP); Marshal.PtrToStructure(ptr, properties[i]); } } finally { if (mustRelease) { DangerousRelease(); } } return(properties); }