簡體   English   中英

Linq錯誤:不包含'InsertOnSubmit'的定義

[英]Linq error: not contain a definition for 'InsertOnSubmit'

我有以下代碼:

   public static bool Update(UserExtendedData data, byte[] image)
        {

            data.UserId = getUserId_new();

            IQueryable<UserExtendedData> entry = m_model.UserExtendedDataSet.Where(x => x.UserId == getUserId_new());
            UserExtendedData User = entry.Single();
            User.firstName = data.firstName;
            User.lastName = data.lastName;
            User.phoneNo = data.phoneNo;
            User.creditCardNo = data.creditCardNo;
            User.dateOfBirth = data.dateOfBirth;
            User.UserId = getUserId_new();

            if (image != null)
            {
                User.avatarArt = image;
            }
            m_model.UserExtendedDataSet.InsertOnSubmit(data);

            return true;
        }

我包括使用System.Data.Linq; 我在Windows 7(x64)上使用asp.net 4.5我還包括:

 <compilation debug="true" targetFramework="4.5">

但我仍然有錯誤:

does not contain a definition for 'InsertOnSubmit' and no extension method 'InsertOnSubmit' accepting a first argument of type ' could be found (are you missing a using directive or an assembly reference?) 

但奇怪的是我沒有遇到任何問題:

public static bool Insert(UserExtendedData data, byte[] image)
        {

            data.UserId = getUserId_new();

                if (image != null)
                    data.avatarArt = image;

                m_model.UserExtendedDataSet.Add(data) ;
                m_model.SaveChanges();
                return true;
        }

你有什么想法會導致這個問題嗎? 我真的很感激任何幫助。

你的Entity set file extension什么? 如果是dbml那么它將在dbmx情況下dbmx

參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM