Building High-Performance modules in DNN6 with C# 4.0
Last Post 08/03/2014 4:39 AM by Jalil Faalkhah. 7 Replies.
Author Messages
mdmiko
Posts:


--
12/21/2012 12:10 PM
    I followed your video,
    when I paste this

    namespace CompanyName.BasicHTML.Components.Data.Model
    {
    public partial class Model
    {
    public static Model Instance()
    {
    var entityBuilder = new System.Data.EntityClient.EntityConnectionStringBuilder();
    entityBuilder.ProviderConnectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString();
    entityBuilder.Metadata = "res://*/";
    entityBuilder.Provider = "System.Data.SqlClient";
    return new Model(entityBuilder.ToString());
    }
    }
    }

    I get an error on last row:
    return new Model(entityBuilder.ToString();
    Visual Studio says that the Model class constructor doesn't accept a string variable as asgument.
    Anyone can help me?
    Joseph Craig
    DNN MVP
    Posts:11667


    --
    12/23/2012 11:29 AM
    Did you create the Model.edmx file following the tutorial? You need to do that and make sure that Model.cs is defined as a partial class so that it shares with the definitions generated in Model.edmx. Unless you do that, there will not be the necessary constructor -- that is, the constructor that takes the string argument.

    Joe Craig, Patapsco Research Group
    Complete DNN Support
    Sara sara
    Nuke Newbie
    Nuke Newbie
    Posts:3


    --
    01/07/2013 5:12 AM
    Hi , I have a question.
    I want to learn Building Modules In DNN6
    i watched video and I did all of the Commands ever , but i have an error.
    help me please
     protected void cmdSave_Click(object sender, EventArgs e)
            {
                try
                {
                    var Model = Components.Data.Model.Model.Instance();
                    //Find the old item and delete it.
                    var OldData = (from x in Model.HTMLs where x.ModuleID == ModuleId select x).FirstOrDefault();
                    if (OldData != null)
                    {
                        Model.DeleteObject(OldData);
                    }
    
                    //Create the new data object.
                    var NewData = new Components.Data.Model.HTML();
                    NewData.ID = Guid.NewGuid();
                    NewData.ModuleID = ModuleId;
                    //The HTML from txtContent is encoded.  Let's decode it.
                    NewData.RawHTML = HttpUtility.HtmlDecode((txtContent as DotNetNuke.UI.UserControls.TextEditor).Text);
                    NewData.CreatedDate = DateTime.Now.ToUniversalTime();
                    NewData.CreatedUserID = UserId;
    
                    Model.HTMLs.AddToHTMLs(NewData);
    
                    //Save the changes
                    Model.SaveChanges();
    
                    //Redirect back to our main page.
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId));
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                }
    
            }
    



    in " Model.HTMLs.AddToHTMLs(NewData);"
    Error 1 'System.Data.Objects.ObjectQuery' does not contain a definition for 'AddToHTMLs' and no extension method 'AddToHTMLs' accepting a first argument of type 'System.Data.Objects.ObjectQuery' could be found (are you missing a using directive or an assembly reference?) E:\SourceDNN\www\Website\DesktopModules\Avang.BasicHTML\BasicHTML_Edit.ascx.cs 54 29 Avang.BasicHTML
    Joseph Craig
    DNN MVP
    Posts:11667


    --
    01/07/2013 8:43 AM
    Sara,

    Without looking, I believe that method should be present in the code created automatically with the edmx file. Make sure that you have that correct, that the namespace is correct and that it matches the namespace in Model.cs. Also, make sure that the class is defined as a partial class in Model.cs.

    Joe Craig, Patapsco Research Group
    Complete DNN Support
    Sara sara
    Nuke Newbie
    Nuke Newbie
    Posts:3


    --
    01/09/2013 3:48 AM
    thanx Joseph Craig for your Answer
    but I think,I did every thing correctly ,
    because I copied each Documents that attached to the video
    i will attach my project to you,please see this
    Joseph Craig
    DNN MVP
    Posts:11667


    --
    01/09/2013 6:22 PM
    Ah ...

    In your code you have: Model.HTMLs.AddToHTMLs(NewData);

    In the tutorial code the line is: Model.HTMLs.AddObject(NewData);

    There is no AddToHTMLs method, and that's exactly what the error message says. It took me reading the code line by line to see this. Of course, had I read the error message and believed/understood it, I would have known exactly what was wrong. The AddObject method is provided by the Entity Framework code.

    Joe Craig, Patapsco Research Group
    Complete DNN Support
    Sara sara
    Nuke Newbie
    Nuke Newbie
    Posts:3


    --
    01/15/2013 6:36 AM
    Thanx A lot ...
    I Got it
    thanx for your help
    Jalil Faalkhah
    Nuke Newbie
    Nuke Newbie
    Posts:1


    --
    08/03/2014 4:39 AM
    I had this problem too. To solve it please change Code generation strategy properties from None to Default of CompanyName.BasicHTML.Components.Data.Model

    To get this properties please click on Model.edmx and the click on white space.

    Best regard,
    Jalil


    ---