我下面演示網編輯直列 它的工作原理,但不會改變數據庫,它只是改變popolated 什麼,我需要做的下列表劍道UI網 - 在線編輯不會更改數據庫
這裏的代碼
public static IList<Book> All()
{
IList<Book> result = (IList<Book>)HttpContext.Current.Session["Books"];
if (result == null)
{
HttpContext.Current.Session["Books"] = result =
(from book in new LibraryModel().Books
select new Book
{
PKiBookID=book.PKiBookID,
SBookName = book.SBookName,
SBookWriter= book.SBookWriter,
SDescription=book.SDescription,
BStatus=book.BStatus,
FKiBookType=book.FKiBookType
}).ToList();
}
return result;
}
public static Book One(Func<Book, bool> predicate)
{
return All().Where(predicate).FirstOrDefault();
}
public static void Insert(Book book)
{
//book.PKiBookID = All().OrderByDescending(p => p.PKiBookID).First().PKiBookID + 1;
All().Insert(0,book);
}
public static void Update(Book book)
{
Book target = One(p => p.PKiBookID == book.PKiBookID);
if (target != null)
{
target.SBookName = book.SBookName;
target.SBookWriter = book.SBookWriter;
target.SDescription = book.SDescription;
target.BStatus = book.BStatus;
target.BookType = new LibraryModel().BookTypes.Single(s => s.PKiBookTypeID == book.FKiBookType);
}
}
我使用螢火蟲,發現錯誤是'串行化'LibraryProject.Book''類型的對象時檢測到循環引用任何關於搜索的建議將有所幫助。課本由openaccess orm(數據庫優先)與asp.net MVC4生成。之後,它仍然插入到數據庫,但我要重建整個解決方案 – user1392853