none
System.NotSupportedException RRS feed

  • Question

  • I have an Entity class as follows..

    <Table> _
    Public Class UserClass
    
        <Column(IsDbGenerated:=True, IsPrimaryKey:=True)> _
        Public Property Id() As Integer
            Get
                Return m_Id
            End Get
            Set(value As Integer)
                m_Id = value
            End Set
        End Property
        Private m_Id As Integer
    
        Public Property FBId() As Integer
            Get
                Return m_FBId
            End Get
            Set(value As Integer)
                m_FBId = value
            End Set
        End Property
        Private m_FBId As Integer
    

    If I use..

    Dim data = From d In dc.Users Where d.Id.Equals(1)
                If Not data.Any Then

    all is good.

    But if I try...

    Dim data = From d In dc.Users Where d.FBId.Equals(1)
                If Not data.Any Then

    I get an exception.   Any ideas why and how to fix this?

    Monday, November 24, 2014 4:19 PM

All replies

  • Hello theresonlyonefinmaf,

    According to your description, I created a table as:

    CREATE TABLE [dbo].[User] (
    
        [Id]   INT NOT NULL,
    
        [FBId] INT NOT NULL,
    
        PRIMARY KEY CLUSTERED ([Id] ASC)
    
    );
    

    And create a console application and add the LINQ2SQL item, pulling the User Table to the designed windows, and testes the two queries provided by you:

    Module Module1
    
    
        Sub Main()
    
            Dim dc As DataClasses1DataContext = New DataClasses1DataContext
    
            Dim data1 = (From d In dc.Users Where d.Id.Equals(1)).ToList()
    
            Dim data2 = (From d In dc.Users Where d.FBId.Equals(1)).ToList()
    
        End Sub
    
    
    End Module
    

    However, both of them work for me.

    >> I have an Entity class as follows.

    Is the provided code all for the entity? I ask because in my side, it is more complex which even has PropertyChanging and PropertyChanged event. And please make sure you are using SQL Server database because as far as I know, the LINQ2SQL is specific for it. And you choose Entity Framework for other databases.

    If you are using SQL Server, please try with my way and if not work, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 25, 2014 3:33 AM
    Moderator
  • I'm using linqtosql on Windows Phone with SQLCE
    Tuesday, November 25, 2014 9:55 AM
  • Hello,

    As far as I know, the LINQ to SQL Visual Studio designer doesn’t support SQL CE by default. In your case, not sure if it is related with the window phone project, do you try use a console application to test it?

    Or use the Entity Framework instead.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 26, 2014 9:59 AM
    Moderator
  • I know that the designer doesn't support CE (sort it out MS!)  Don't know if it's relevant but there is no data in the table currently.  I notice both your columns are defined as Not Null, could the difference in my definitions be causing something strange ?
    Wednesday, November 26, 2014 1:46 PM
  • Hello,

    >>could the difference in my definitions be causing something strange ?

    After modifying the table to:

    CREATE TABLE [dbo].[User] (
    
        [Id]   INT NULL,
    
        [FBId] INT NULL
    
    );
    

    and

    CREATE TABLE [dbo].[User] (
    
        [Id]   INT NOT NULL,
    
        [FBId] INT NULL, 
    
        CONSTRAINT [PK_User] PRIMARY KEY ([Id])
    
    );
    

    However, both of them work as excepted. If it is possible, please try with a sql server database.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 27, 2014 9:39 AM
    Moderator