Example #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets entity object by specified data object.
        /// </summary>
        /// <param name="dataObject">
        /// DataObject object.
        /// </param>
        /// <returns>
        /// EntityObject object.
        /// </returns>
        public static EntityObject GetEntityObject(DataObject dataObject)
        {
            Debug.Assert(dataObject != null);

            IRawDataAccess dataAccess = dataObject as IRawDataAccess;

            if (dataAccess == null)
            {
                throw new DataException(Properties.Messages.Error_InvalidDataObjectInstance);
            }

            return(dataAccess.RawEntity);
        }
        private T _FindObject(EntityObject entity)
        {
            T res = null;

            foreach (T obj in _dataObjects)
            {
                IRawDataAccess dataAccess = obj as IRawDataAccess;
                if (dataAccess != null)
                {
                    if (dataAccess.RawEntity.Equals(entity))
                    {
                        res = obj;
                        break;
                    }
                }
            }

            return(res);
        }