none
System.Data.EntityException HResult=0x80131501 Error RRS feed

  • Question

  • Hello folks,

    I am using sqllite in my project. I get error in the method below and I can't figure out what's wrong:

    public WordPoco GetWord(string stWord)
            {
                WordPoco wordPoco = new WordPoco();

                using (var dic = new DictionaryRepository())
                {
                    if (dic.Contains(stWord))  (<-- here)
                        wordPoco = dic.GetWord(stWord);
                }
                return wordPoco;
            }


    System.Data.EntityException
      HResult=0x80131501
      Message = base provider error in Open.
      Source = <
    Unable to determine the source of exception>
      Трассировка стека:
       at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
       at System.Data.EntityClient.EntityConnection.Open()
       at System.Data.Objects.ObjectContext.EnsureConnection()
       at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
       at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
       at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)

    Monday, April 3, 2017 7:07 PM

Answers

  • Hi hokushin,

    According to your description and related code. it seems that variable does not have a method named 'Contains'.

    Could you please provide a bit more information, such as the code DictionaryRepository class, which we'll could reproduce your issue on my side.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by hokushin Wednesday, April 5, 2017 5:59 AM
    Tuesday, April 4, 2017 5:52 AM
    Moderator

All replies

  • Hi hokushin,

    According to your description and related code. it seems that variable does not have a method named 'Contains'.

    Could you please provide a bit more information, such as the code DictionaryRepository class, which we'll could reproduce your issue on my side.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by hokushin Wednesday, April 5, 2017 5:59 AM
    Tuesday, April 4, 2017 5:52 AM
    Moderator
  • Thanks a lot for prompt reply, please find below the code in question:

    public class DictionaryRepository : Repository<WordPoco>, IDictionaryRepository, IRepository<WordPoco>, IDisposable
    	{
    		public DictionaryContext Context
    		{
    			get;
    			set;
    		}
    
    		public DictionaryRepository() : base(new DictionaryContext(ConnectionBuilder.GetConnection(), true))
    		{
    			this.Context = (DictionaryContext)base.BaseContext;
    		}
    
    		public bool Contains(string stWord)
    		{
    			bool flag; 
    			flag = (this.Context.Words.Count<WordPoco>((WordPoco w) => w.Word == stWord) <= 0 ? false : true);
    			return flag;
    		}
    
    		public int Count()
    		{
    			return this.Context.Words.Count<WordPoco>();
    		}
    
    		public WordPoco GetWord(string stWord)
    		{
    			WordPoco wordPoco = new WordPoco();
    			wordPoco = this.Context.Words.First<WordPoco>((WordPoco w) => w.Word == stWord);
    			return wordPoco;
    		}
    	}


    Tuesday, April 4, 2017 9:22 AM
  • Hi hokushin,

    Based on the code you provide. it seems that it has custom method. which I am not sure what line of code causes the issue. Could you please provide a simple complete code via OneDrive, which could reproduce the issue. we'll reproduce the issue on my side and try to find a solution to resolve it.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 5, 2017 5:57 AM
    Moderator