1

Class 1

public partial class Profile : BaseEntity
{
    #region Properties
    /// <summary>
    /// Gets or sets the Profile identifier
    /// </summary>
    public int ProfileId { get; set; }

    /// <summary>
    /// Gets or sets the FullName
    /// </summary>
    public string FullName { get; set; }

    /// <summary>
    /// Gets or sets the Gender
    /// </summary>
    public string Gender { get; set; }

    /// <summary>
    /// Gets or sets the DateofBirth
    /// </summary>
    public DateTime DateofBirth { get; set; }

}

Class 2

   public partial interface IProfileService
   {

    /// <summary>
    /// Gets an Profile by profile identifier
    /// </summary>
    /// <param name="profileid">profile identifier</param>
    /// <returns>Profile</returns>
     Profile GetProfileById(int profileid);


    /// <summary>
    /// Gets all Profiles
    /// </summary>
    /// <returns>Profile collection</returns>
    List<Profile> GetAllProfiles();

   }

Class 3

  public partial class ProfileService : IProfileService
 {      
     /// <summary>
    /// Gets a profile by profile identifier
    /// </summary>
    /// <param name="profileId">Profile identifier</param>
    /// <returns>profile</returns>
    public Profile GetProfileById(int profileid)
    {
        if (profileid == 0)
            return null;


        var query = from a in _context.Profilemasters
                    where a.ProfileId == profileid
                    select a;
        var profile = query.SingleOrDefault();

        return profile;
    }
  }

In Class 3 of return profile I get an error Message that "Cannot Implicitly Convert 'Data.Profilemaster' to 'Library.Profile'. Whareas Data.Profilemaster is an Entity table amd Library.Profile is Class ie. Class 1.

And when I use "MyContext.Profilemasters.AddObject(profile);" command to insert data I get another Error Message ie. "The Best Overloaded Method match for...."

Please help Me.

I am New in Entrity Framework.

Anybody has the Idea to solve this

2
  • How did you get your Profile class? How did you create mapping? Commented Mar 3, 2011 at 13:32
  • I am using all these Class in a Folder of the Project Commented Mar 4, 2011 at 4:22

1 Answer 1

1

Try Like This .........

 public ModelTest GetTest(int id)
    {
        ModelTest ob = new ModelTest();
        var a = from r in _QEntities.Tests
                where r.id == id
                select r;
        foreach (var item in a)
        {
            ob.TestName = item.name;
            ob.TotalMarks = item.totalmarks;
        }

        return ob;
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.