views:

488

answers:

1

I have dbml with single table users

i want add partial class for User and add another property like so:

    public partial class User
    {
        public string FullName
        {
            get
            {
                return FirstName + " " + LastName;
            }
        }
    }

and then use in my View something like:

<%=ViewData.Model.FullName %>

here what im getting:

CS1061: 'PR.Web.Models.User' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'PR.Web.Models.User' could be found (are you missing a using directive or an assembly reference?)

what im doing wrong???

A: 

Double check the namespace of the generated LINQ to SQL class (User) and the partial class.

You may be sure that it's "all definitely correct", but the compiler is telling you otherwise. Post the relevant sections of the .designer.cs file nested under your .dbml file if necessary, as well as the full source for the file that contains the User class you posted above.

Brannon
same namespace PR.Web.Models, if remove partial from User class getting: Missing partial modifier on declaration of type 'PR.Web.Models.User'; another partial declaration of this type exists sounds like no problems with namespaces :(
msony
Are both halves of the partial class in the same assembly? Can you use the property from code-behind? Do you only get the error when using the property from a view?
Brannon
may be i forgot compile the code, now its ok, thanks :)
msony