I’m trying to convert the vb code (below) to c#. The c# code a the bottom doesn’t like the this.UserLogin or this.CompanyID, this.CompanyType or this.CreatedDateTime. It gives the error CT_CompanyLogin does not contain a definition for UserLogin and no extension method UserLogin accepting a first argument of type CT_CompanyLogin could be found (are you missing a using directive or an assembly reference?)
Any help??
VB
Partial Class CT_CompanyLogin
Public Function GetCompanyAssoicatedByUserID() As Boolean
Dim db As DataClassesDataContext = New DataClassesDataContext()
Try
Dim mycompany = (From c In db.CT_CompanyLogIns _
Where c.UserLogIn = Me.UserLogIn _
Select c).Single
Me.CompanyID = mycompany.CompanyID
Me.CompanyType = mycompany.CompanyType
Me.CreatedDateTime = mycompany.CreatedDateTime
Return True
Catch ex As Exception
Return False
End Try
End Function
End Class
C#
partial class CT_CompanyLogin
{
public Boolean GetCompanyAssociatedByUserID()
{
DataClassesDataContext db = new DataClassesDataContext();
try
{
var mycompany = (from c in db.CT_CompanyLogIns
where c.UserLogIn == this.UserLogin
select c).Single();
this.CompanyID = mycompany.CompanyID;
this.CompanyType = mycompany.CompanyType;
this.CreatedDateTime = mycompany.CreatedDateTime;
return true;
}
catch (Exception ex)
{
return false;
}
}
}
It was the wrong spelling, vb is not case sensitive where c# is, so in the partial classes one was CT_CompanyLogIn and the other was CT_CompanyLogin