public XObjectRelation Get(Guid Id)
        {
            XObjectRelation relation = null;

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

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

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

                relation = new XObjectRelation();

                rdr.Read();

                if (!rdr.IsDBNull(rdr.GetOrdinal("FromAssetId")))
                {
                    relation.FromAssetId = rdr.GetGuid(rdr.GetOrdinal("FromAssetId"));
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("ToAssetId")))
                {
                    relation.ToAssetId = rdr.GetGuid(rdr.GetOrdinal("ToAssetId"));
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("AssetRelationTypeId")))
                {
                    relation.AssetRelationType = EnumerationOps.EAssetRelationTypeFromValue((Int16)rdr.GetByte(rdr.GetOrdinal("AssetRelationTypeId")));
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("Created")))
                {
                    relation.Created = (DateTime)rdr[rdr.GetOrdinal("Created")];
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("Approved")))
                {
                    relation.Approved = (DateTime)rdr[rdr.GetOrdinal("Approved")];
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("CreatedBy")))
                {
                    relation.CreatedBy = rdr.GetGuid(rdr.GetOrdinal("CreatedBy"));
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("ApprovedBy")))
                {
                    relation.ApprovedBy = rdr.GetGuid(rdr.GetOrdinal("ApprovedBy"));
                }

                if (!rdr.IsDBNull(rdr.GetOrdinal("DeletedBy")))
                {
                    relation.DeletedBy = rdr.GetGuid(rdr.GetOrdinal("DeletedBy"));
                }

                relation.Id      = Id;
                relation.IsNew   = false;
                relation.IsDirty = false;
            }

            return(relation);
        }
        public List <XObjectRelation> AssetRelationList_GetByFromAssetId(Guid fromassetid)
        {
            List <XObjectRelation> list = new List <XObjectRelation>();

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

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

            using (SqlDataReader drdSql = base.OpenDataReader(spAssetAssetRelationList_GetByFromAssetId, paramList))
            {
                if ((drdSql != null) && (drdSql.HasRows))
                {
                    //get the index of each property we are going to load
                    int Id                  = drdSql.GetOrdinal("Id");
                    int FromAssetId         = drdSql.GetOrdinal("FromAssetId");
                    int ToAssetId           = drdSql.GetOrdinal("ToAssetId");
                    int AssetRelationTypeId = drdSql.GetOrdinal("AssetRelationTypeId");
                    int Created             = drdSql.GetOrdinal("Created");
                    int Approved            = drdSql.GetOrdinal("Approved");
                    int CreatedBy           = drdSql.GetOrdinal("CreatedBy");
                    int ApprovedBy          = drdSql.GetOrdinal("ApprovedBy");
                    int DeletedBy           = drdSql.GetOrdinal("DeletedBy");

                    while (drdSql.Read())
                    {
                        XObjectRelation relation = new XObjectRelation();

                        if (!drdSql.IsDBNull(Id))
                        {
                            relation.Id = drdSql.GetGuid(Id);
                        }

                        if (!drdSql.IsDBNull(FromAssetId))
                        {
                            relation.FromAssetId = drdSql.GetGuid(FromAssetId);
                        }

                        if (!drdSql.IsDBNull(ToAssetId))
                        {
                            relation.ToAssetId = drdSql.GetGuid(ToAssetId);
                        }

                        if (!drdSql.IsDBNull(AssetRelationTypeId))
                        {
                            relation.AssetRelationType = EnumerationOps.EAssetRelationTypeFromValue((Int16)drdSql.GetByte(AssetRelationTypeId));
                        }

                        if (!drdSql.IsDBNull(Created))
                        {
                            relation.Created = (DateTime)drdSql.GetValue(Created);
                        }

                        if (!drdSql.IsDBNull(Approved))
                        {
                            relation.Approved = (DateTime)drdSql.GetValue(Approved);
                        }

                        if (!drdSql.IsDBNull(CreatedBy))
                        {
                            relation.CreatedBy = drdSql.GetGuid(CreatedBy);
                        }

                        if (!drdSql.IsDBNull(ApprovedBy))
                        {
                            relation.ApprovedBy = drdSql.GetGuid(ApprovedBy);
                        }

                        if (!drdSql.IsDBNull(DeletedBy))
                        {
                            relation.DeletedBy = drdSql.GetGuid(DeletedBy);
                        }

                        relation.IsNew   = false;
                        relation.IsDirty = false;

                        list.Add(relation);
                    }
                }
            }

            return(list);
        }