Exemplo n.º 1
0
        public IDictionary <Guid, IXProperty> GetObjectDictionary(IList <Guid> propertyIds)
        {
            string propIds = Helpers.ListOfGuidToCommaDelimString(propertyIds);

            IDictionary <Guid, IXProperty> values = new Dictionary <Guid, IXProperty>();

            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@PropertyIds", propIds));

            using (SqlDataReader rdr = base.OpenDataReader(StoredProcs.Properties_GetObjectDictionary, paramList))
            {
                if ((rdr == null) || (!rdr.HasRows))
                {
                    return(values);
                }

                int Id                  = rdr.GetOrdinal("Id");
                int Name                = rdr.GetOrdinal("Name");
                int DisplayValue        = rdr.GetOrdinal("DisplayValue");
                int Description         = rdr.GetOrdinal("Description");
                int DataTypeId          = rdr.GetOrdinal("DataTypeId");
                int IsSystem            = rdr.GetOrdinal("IsSystem");
                int SystemTypeId        = rdr.GetOrdinal("SystemTypeId");
                int Precision           = rdr.GetOrdinal("Precision");
                int PickListId          = rdr.GetOrdinal("PickListId");
                int RoleId              = rdr.GetOrdinal("RoleId");
                int IsOrdered           = rdr.GetOrdinal("IsOrdered");
                int AllowMultiValue     = rdr.GetOrdinal("AllowMultiValue");
                int Singular            = rdr.GetOrdinal("Singular");
                int Plural              = rdr.GetOrdinal("Plural");
                int AssetTypeId         = rdr.GetOrdinal("AssetTypeId");
                int AssetTypeIsInstance = rdr.GetOrdinal("AssetTypeIsInstance");
                int Created             = rdr.GetOrdinal("Created");
                int CreatedBy           = rdr.GetOrdinal("CreatedBy");
                //int Approved = rdr.GetOrdinal("Approved");
                //int ApprovedBy = rdr.GetOrdinal("ApprovedBy");
                int LastModified   = rdr.GetOrdinal("LastModified");
                int LastModifiedBy = rdr.GetOrdinal("LastModifiedBy");
                int Deleted        = rdr.GetOrdinal("Deleted");
                int DeletedBy      = rdr.GetOrdinal("DeletedBy");

                while (rdr.Read())
                {
                    XProperty property = new XProperty();

                    property.Id = rdr.GetGuid(Id);

                    if (!rdr.IsDBNull(Name))
                    {
                        property.Name = rdr.GetString(Name);
                    }

                    if (!rdr.IsDBNull(DisplayValue))
                    {
                        property.DisplayValue = rdr.GetString(DisplayValue);
                    }

                    if (!rdr.IsDBNull(Description))
                    {
                        property.Description = rdr.GetString(Description);
                    }

                    if (!rdr.IsDBNull(DataTypeId))
                    {
                        property.DataType = EnumerationOps.EDataTypeFromValue((Int16)rdr.GetByte(DataTypeId));
                    }

                    if (!rdr.IsDBNull(IsSystem))
                    {
                        property.IsSystem = (bool)rdr[IsSystem];
                    }

                    if (!rdr.IsDBNull(SystemTypeId))
                    {
                        property.SystemType = EnumerationOps.ESystemTypeFromValue(rdr.GetInt32(SystemTypeId));
                    }

                    if (!rdr.IsDBNull(Precision))
                    {
                        property.Precision = (Int16)rdr[Precision];
                    }

                    if (!rdr.IsDBNull(PickListId))
                    {
                        property.XListId = rdr.GetGuid(PickListId);
                    }

                    if (!rdr.IsDBNull(RoleId))
                    {
                        property.RoleId = rdr.GetGuid(RoleId);
                    }

                    if (!rdr.IsDBNull(IsOrdered))
                    {
                        property.IsOrdered = (bool)rdr[IsOrdered];
                    }

                    if (!rdr.IsDBNull(AllowMultiValue))
                    {
                        property.AllowMultiValue = (bool)rdr[AllowMultiValue];
                    }

                    if (!rdr.IsDBNull(Singular))
                    {
                        property.Singular = rdr.GetString(Singular);
                    }

                    if (!rdr.IsDBNull(Plural))
                    {
                        property.Plural = rdr.GetString(Plural);
                    }

                    if (!rdr.IsDBNull(AssetTypeId))
                    {
                        property.XObjectTypeId = rdr.GetGuid(AssetTypeId);
                    }

                    if (!rdr.IsDBNull(AssetTypeIsInstance))
                    {
                        property.AssetTypeIsInstance = (bool)rdr[AssetTypeIsInstance];
                    }

                    property.Created   = rdr.GetDateTime(Created);
                    property.CreatedBy = rdr.GetGuid(CreatedBy);

                    if (!rdr.IsDBNull(LastModified))
                    {
                        property.LastModified = rdr.GetDateTime(LastModified);
                    }
                    if (!rdr.IsDBNull(LastModifiedBy))
                    {
                        property.LastModifiedBy = rdr.GetGuid(LastModifiedBy);
                    }

                    if (!rdr.IsDBNull(Deleted))
                    {
                        property.Deleted = rdr.GetDateTime(Deleted);
                    }
                    if (!rdr.IsDBNull(DeletedBy))
                    {
                        property.DeletedBy = rdr.GetGuid(DeletedBy);
                    }

                    property.IsNew   = false;
                    property.IsDirty = false;

                    values.Add(property.Id, property);
                }
            }

            return(values);
        }
Exemplo n.º 2
0
        public XProperty Get(Guid id)
        {
            XProperty property = null;

            List <SqlParameter> paramList = paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@Id", id));

            using (SqlDataReader rdr = base.OpenDataReader(StoredProcs.Property_Get, paramList))
            {
                if ((rdr == null) || (!rdr.HasRows))
                {
                    return(null);
                }

                int Name                = rdr.GetOrdinal("Name");
                int DisplayValue        = rdr.GetOrdinal("DisplayValue");
                int Description         = rdr.GetOrdinal("Description");
                int DataTypeId          = rdr.GetOrdinal("DataTypeId");
                int IsSystem            = rdr.GetOrdinal("IsSystem");
                int SystemTypeId        = rdr.GetOrdinal("SystemTypeId");
                int Precision           = rdr.GetOrdinal("Precision");
                int PickListId          = rdr.GetOrdinal("PickListId");
                int RoleId              = rdr.GetOrdinal("RoleId");
                int IsOrdered           = rdr.GetOrdinal("IsOrdered");
                int AllowMultiValue     = rdr.GetOrdinal("AllowMultiValue");
                int Singular            = rdr.GetOrdinal("Singular");
                int Plural              = rdr.GetOrdinal("Plural");
                int AssetTypeId         = rdr.GetOrdinal("AssetTypeId");
                int AssetTypeIsInstance = rdr.GetOrdinal("AssetTypeIsInstance");
                int Created             = rdr.GetOrdinal("Created");
                int CreatedBy           = rdr.GetOrdinal("CreatedBy");
                //int Approved = rdr.GetOrdinal("Approved");
                //int ApprovedBy = rdr.GetOrdinal("ApprovedBy");
                int LastModified   = rdr.GetOrdinal("LastModified");
                int LastModifiedBy = rdr.GetOrdinal("LastModifiedBy");
                int Deleted        = rdr.GetOrdinal("Deleted");
                int DeletedBy      = rdr.GetOrdinal("DeletedBy");

                property = new XProperty();

                rdr.Read();

                property.Id = id;

                if (!rdr.IsDBNull(Name))
                {
                    property.Name = rdr.GetString(Name);
                }

                if (!rdr.IsDBNull(DisplayValue))
                {
                    property.DisplayValue = rdr.GetString(DisplayValue);
                }

                if (!rdr.IsDBNull(Description))
                {
                    property.Description = rdr.GetString(Description);
                }

                if (!rdr.IsDBNull(DataTypeId))
                {
                    property.DataType = EnumerationOps.EDataTypeFromValue((Int16)rdr.GetByte(DataTypeId));
                }

                if (!rdr.IsDBNull(IsSystem))
                {
                    property.IsSystem = (bool)rdr[IsSystem];
                }

                if (!rdr.IsDBNull(SystemTypeId))
                {
                    property.SystemType = EnumerationOps.ESystemTypeFromValue(rdr.GetInt32(SystemTypeId));
                }

                if (!rdr.IsDBNull(Precision))
                {
                    property.Precision = (Int16)rdr[Precision];
                }

                if (!rdr.IsDBNull(PickListId))
                {
                    property.XListId = rdr.GetGuid(PickListId);
                }

                if (!rdr.IsDBNull(RoleId))
                {
                    property.RoleId = rdr.GetGuid(RoleId);
                }

                if (!rdr.IsDBNull(IsOrdered))
                {
                    property.IsOrdered = (bool)rdr[IsOrdered];
                }

                if (!rdr.IsDBNull(AllowMultiValue))
                {
                    property.AllowMultiValue = (bool)rdr[AllowMultiValue];
                }

                if (!rdr.IsDBNull(Singular))
                {
                    property.Singular = rdr.GetString(Singular);
                }

                if (!rdr.IsDBNull(Plural))
                {
                    property.Plural = rdr.GetString(Plural);
                }

                if (!rdr.IsDBNull(AssetTypeId))
                {
                    property.XObjectTypeId = rdr.GetGuid(AssetTypeId);
                }

                if (!rdr.IsDBNull(AssetTypeIsInstance))
                {
                    property.AssetTypeIsInstance = (bool)rdr[AssetTypeIsInstance];
                }

                property.Created   = rdr.GetDateTime(Created);
                property.CreatedBy = rdr.GetGuid(CreatedBy);

                if (!rdr.IsDBNull(LastModified))
                {
                    property.LastModified = rdr.GetDateTime(LastModified);
                }
                if (!rdr.IsDBNull(LastModifiedBy))
                {
                    property.LastModifiedBy = rdr.GetGuid(LastModifiedBy);
                }

                if (!rdr.IsDBNull(Deleted))
                {
                    property.Deleted = rdr.GetDateTime(Deleted);
                }
                if (!rdr.IsDBNull(DeletedBy))
                {
                    property.DeletedBy = rdr.GetGuid(DeletedBy);
                }

                property.IsNew   = false;
                property.IsDirty = false;
            }

            return(property);
        }