public List<Media_PlayLists> LoadDatedItemsByPage(string status, int startRow, int pageSize, string sortBy, bool sortAscending)
        {
            using (MediaEntities dbContext = new MediaEntities())
            {
                SortData(sortBy, sortAscending);
                //copy to an array
                int count = pageSize;
                _items = GetListByStatus(status);
                if ((_items.Count - startRow) < count) count = _items.Count - startRow;
                Media_PlayLists[] pagearray = new Media_PlayLists[count];

                _items.CopyTo(startRow, pagearray, 0, count);
                //then create a list from array
                List<Media_PlayLists> page = new List<Media_PlayLists>(pagearray);
                return page;

                //_items = (from p in dbContext.Media_PlayLists select p).OrderBy(x => x.SortOrder).Skip(startRow * pageSize).Take(pageSize).ToList();
                //return _items;
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Media_PlayLists EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMedia_PlayLists(Media_PlayLists media_PlayLists)
 {
     base.AddObject("Media_PlayLists", media_PlayLists);
 }
 /// <summary>
 /// Create a new Media_PlayLists object.
 /// </summary>
 /// <param name="typeId">Initial value of the TypeId property.</param>
 /// <param name="playListId">Initial value of the PlayListId property.</param>
 public static Media_PlayLists CreateMedia_PlayLists(global::System.Int32 typeId, global::System.Int32 playListId)
 {
     Media_PlayLists media_PlayLists = new Media_PlayLists();
     media_PlayLists.TypeId = typeId;
     media_PlayLists.PlayListId = playListId;
     return media_PlayLists;
 }
        //INSERT- UPDATE - DELETE 
        public int Insert(string UserId, int TypeId, string PlayListName, string FrontImage, string MainImage, string Description, string Status)
        {
            using (MediaEntities dbContext = new MediaEntities())
            {
                string Alias = StringUtils.GenerateFriendlyString(PlayListName);
                dbContext.CommandTimeout = Settings.CommandTimeout;
                System.Nullable<Int32> SortOrder = (from u in dbContext.Media_PlayLists select u.SortOrder).DefaultIfEmpty(0).Max() + 1;

                Media_PlayLists entity = new Media_PlayLists();
                entity.TypeId = TypeId;
                entity.PlayListName = PlayListName;
                entity.Alias = Alias;
                entity.FrontImage = FrontImage;
                entity.MainImage = MainImage;
                entity.Description = Description;
                entity.SortOrder = (SortOrder == null ? 1 : SortOrder);
                entity.IPLog = IP;
                entity.CreatedOnDate = System.DateTime.Now;
                entity.CreatedByUserId = new Guid(UserId);
                entity.Status = Status;
                dbContext.AddToMedia_PlayLists(entity);
                int i  = dbContext.SaveChanges();
                return i;
            }
        }