Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 143 posts 253 karma points
    Jan 20, 2015 @ 12:52
    Tom
    0

    C# LINQ and Umbraco

    Hi:

    I'm new to Umbraco.

    After a successful install, I have created my first a document type called NewsLine.  It has 3 the following Generic properties (Title (text), Contents (RTE) and Article Date (DatePicker) 

    I wish to create a C# console application to populate the associated Umbraco table with 10,000 rows of data.

    Does anyone have a C# asp.NET LINQ example stub to get me started.

    Thanks

     

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Jan 20, 2015 @ 15:41
    Alex Skrypnyk
    0

    Hi Tom,

    You can easily use Umbraco Services for retrieving and manipulating data from Umbraco.

    http://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService

    Thanks

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Jan 20, 2015 @ 15:41
    Jeavon Leopold
    0

    Hi Tom,

    I've not used it but there is a example console application here that uses the ContentService to create content.

    Jeavon

  • Tom 143 posts 253 karma points
    Jan 20, 2015 @ 20:49
    Tom
    0

    jeavon:

     

    Thank you very much for the link.  However, I am having trouble with the console application.

    After changing the umbracoDbDSN connection string I recompiled the console application and ran it.  It worked!

    Note:  Iam using VS 2013.

    But when I ran it the second thrid time, my VIsual Studio debugger errored out on this line.

     

    {"Could not load types from assembly umbraco, Version=1.0.5133.26615, Culture=neutral, PublicKeyToken=null, errors:\r\nException: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.\r\nFile name: 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'\r\n\r\n=== Pre-bind state information ===\r\nLOG: DisplayName = System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\n (Fully-specified)\r\nLOG: Appbase = file:///C:/work/fhlb/UmbracoConsole/UmbConsole/bin/Debug/\r\nLOG: Initial PrivatePath = NULL\r\nCalling assembly : System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: C:\\work\\fhlb\\UmbracoConsole\\UmbConsole\\bin\\Debug\\UmbConsole.vshost.exe.Config\r\nLOG: Using host configuration file: \r\nLOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\config\\machine.config.\r\nLOG: Redirect found in application configuration file: 2.0.0.0 redirected to 2.0.0.0.\r\nLOG: Post-policy reference: System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\r\nLOG: Attempting download of new URL file:///C:/work/fhlb/UmbracoConsole/UmbConsole/bin/Debug/System.Net.Http.DLL.\r\nLOG: Attempting download of new URL file:///C:/work/fhlb/UmbracoConsole/UmbConsole/bin/Debug/System.Net.Http/System.Net.Http.DLL.\r\nLOG: Attempting download of new URL file:///C:/work/fhlb/UmbracoConsole/UmbConsole/bin/Debug/System.Net.Http.EXE.\r\nLOG: Attempting download of new URL file:///C:/work/fhlb/UmbracoConsole/UmbConsole/bin/Debug/System.Net.Http/System.Net.Http.EXE.\r\n\r\n"}

     

    I went to Task Manager and thought maybe there was something loaded that did not get unlaoded when I stopped the debugger.  I found UmbConsole.vshost.exe file hanging around.  But when I deleted it, it came back.

    Have you seen this?  

    What can I do?

     

    Thanks


    Tom

  • Tom 143 posts 253 karma points
    Jan 20, 2015 @ 20:54
    Tom
    0

    Oh I am using Umbraco 7 and code fails on this line.

    protected override void InitializeApplicationEventsResolver()
           {            
    base.InitializeApplicationEventsResolver();
    }

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Jan 20, 2015 @ 21:03
    Jeavon Leopold
    0

    To start I would suggest updating the UmbracoCms.Core NuGet package to v7.2.1 as a lot has changed since v7.0.2 and see if it still compiles...?

  • Tom 143 posts 253 karma points
    Jan 21, 2015 @ 12:50
    Tom
    0

    Jeavon:

     

    Actually I am on 7.2.1.  The code compiles and runs great the first time.  After that, I'm getting the above mentioned VS error.

    I realinze you did not write the code and was only being helpful.  But have you tried running the code?

     

    Thanks

     

    Tom

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies