dennis schütz
dennis schütz

Reputation: 383

Converter ID to object

I have a Converter class which I give a ID. With this ID I want to get a object as return value. But I have an Error which I don't know how to fix. The error appears at:

result = ArbeitsplatzgruppeNT.Get(arbeitsplatzgruppeId);

In my Convert Method and my ConvertBack Method is just working fine.

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    ArbeitsplatzgruppeNT result = null;
    Guid arbeitsplatzgruppeId = Guid.Empty;

    if (value != null && Guid.TryParse(value.ToString(), out arbeitsplatzgruppeId) && arbeitsplatzgruppeId != Guid.Empty)
    {
        try
        {
            result = ArbeitsplatzgruppeNT.Get(arbeitsplatzgruppeId); // Error 
        }

        catch (Exception)
        {
        }
    }

    return result;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    Guid result = Guid.Empty;

    if (value != null && value is ArbeitsplatzgruppeNT)
    {
        result = (value as ArbeitsplatzgruppeNT).ID;
    }

    return result;
}

That's my GET methods in the Business-Class

public static ArbeitsplatzgruppeNT Get(Guid ID)
{
    return DataPortal.FetchChild<ArbeitsplatzgruppeNT>(ID);
}

And that's my Error:

Error 2 The type 'HGERP.Data.ArbeitsplatzGruppe' is defined in an assembly that is not referenced. You must add a reference to assembly 'HGERP.DataLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

It got to do something with my business-class because I got already a version which is working. but I had to replace the ArbeitsplatzgruppeNT-class and now its not working anymore. but there isn't not a big difference between old an new ...

Upvotes: 0

Views: 255

Answers (2)

Joe
Joe

Reputation: 1305

You likely need some pre-compiler directives around your data access code and relevant using statements, like

#if !SILVERLIGHT
using MyProject.DataAccess;
#endif

Otherwise, the SL business project will be looking for references it can't have.

Upvotes: 0

bbqchickenrobot
bbqchickenrobot

Reputation: 3709

Where is your 'HGERP.Data.ArbeitsplatzGruppe' class defined? If it is in another dll or project you will need to reference that specific dll or project from your mvc project. You can right click the references section to add an assembly reference.

Upvotes: 1

Related Questions