Giter Site home page Giter Site logo

umbracolinqpaddriver's Introduction


❤️ If you use and like the LinqPad driver for Umbraco please consider becoming a GitHub Sponsor ❤️

A LinqPad driver for Umbraco

This allows you to easily query data in an Umbraco installation. All you need to do is add a LinqPad connection and point it to your Umbraco folder! Then you can easily query against media and content but best of all it allows you to run scripts against an Umbraco installation using your favorite Umbraco Service APIs.

What a demo? https://www.youtube.com/watch?feature=player_embedded&v=ypPvOQY8sF0

  • v2.0.0 supports Umbraco 7.7+
  • v1.0.0 supports 7.2+ and < 7.5

Installation

Basic Usage

  • Expand either Content/Media
  • Right click and choose a query (i.e.Take 100)
  • The query will display on the right, you can modify it and execute it

Scripting

The Umbraco LinqPad Driver's data context exposes the Umbraco ApplicationContext as 'ApplicationContext' so you can write whatever queries you want against the Umbraco services or DatabaseContext, etc... for example you could just write:

ApplicationContext.Services.ContentService.GetRootContent()

And it will show you the root content

Since LinqPad supports c# statements, etc.. you could write full scripts and even persist things back to your database

IMPORTANT Notes

Here's some important things to know:

  • This will not load your custom plugins, your custom events will not fire
  • This does not do anything regarding the web context
  • The content xml, lucene indexes, etc... will not be updated if you choose to start persisting stuff with the ApplicationContext
  • Do not persist data on a live environment unless you really know what you are doing... actually don't persist stuff at all unless you know what you are doing :)
  • This driver does NOT use IQueryable, all data returned from the LinqPad tree is IEnumerable, so any filtering you are doing is based on all of the results returned and then filtered in memory - It will be slow if you have tons of data
    • IQueryable support will come later I've already started some POCs for that

umbracolinqpaddriver's People

Contributors

shazwazza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

umbracolinqpaddriver's Issues

Event handlers will not run when performing write operations

I do not think this is fixable, but I thought I'd note that event handlers wired up in the website code will not run when you do write operations from LINQPad. This only makes sense, since those are in the web server context, which doesn't apply here.

Something to be aware of.

Possible to query using PublishedContentQuery?

I didn't look much on the code yet, since this is at the bottom of the stack atm.
But instead of exposing custom runtime-generated model types for LinqPad, shouldn't it be possible to query on PublishedContentQuery.TypedContent()?
If you've got custom models, you can add an assembly reference to the query (i think), so it should be possible for PublishedContentModelFactory to resolve the types.
If no custom reference, they'll be whatever is configured for published content. (IE. XmlPublishedContent).
Possible, no?

Membership provider error when saving content

When I tried to save content, I ran into an error:

No membership provider found with name UsersMembershipProvider

(Weirdly, I was able to delete content just fine. I only had a problem when saving it.)

The problem is that you can't manually add a provider because the collection is read-only. They're added from the web.config in the web context, I think. I tried a bunch of stuff, but ended up solving this with a horrible, horrible hack -- I reflect the read-only property and manually add a provider.

(Warning: this is bad. But it worked. Also, it was stolen from Stack Overflow...)

// MASSIVE HACK: this manually adds a membership provider in the worst way possible... :-0
var provider = new Umbraco.Web.Security.Providers.UsersMembershipProvider();
provider.Initialize("UsersMembershipProvider", new NameValueCollection());
provider.AddTo(Membership.Providers);

public static class ProviderUtil
{
	static private FieldInfo providerCollectionReadOnlyField;

	static ProviderUtil()
	{
		Type t = typeof(ProviderCollection);
		providerCollectionReadOnlyField = t.GetField("_ReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
	}

	static public void AddTo(this ProviderBase provider, ProviderCollection pc)
	{
		bool prevValue = (bool)providerCollectionReadOnlyField.GetValue(pc);
		if (prevValue)
			providerCollectionReadOnlyField.SetValue(pc, false);

		pc.Add(provider);

		if (prevValue)
			providerCollectionReadOnlyField.SetValue(pc, true);
	}
}

Properties with the aliases that match keywords fail

One of my content type property aliases is called 'abstract'. While potentially short sighted this makes sense from an article perspective but as you're using the alias when building the POCOs I'm getting an error when trying to connect to my website path.
Exception - Cannot compile typed context: Member modifier 'abstract' must precede the member type and name

I can see where to escape the member name in your solution but I've no idea where I'll then have to unescape it.

No worries about fixing this for me, as I'll take another approach, but I thought I'd log the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.