Umm, I haven't needed to install uComponents yet ... and I'd rather not if I can avoid it.
I wanted to link a content document with a media folder by name, programmatically, rather than a content editor having to set it up. However, maybe I would be much better off (make my life easier!) if I put a Media Picker on the content node!
I'm currently using uComponents in my solution. When using uQuery.GetMediaByName I'm using lambda expression to check that a folders exists and if it doesn't create it.
I'm trying to debug this in VS but I'm getting an error message "Expression cannot contain lambda expressions". Forgive the stupid question but is this VS Immediate Window being rubbish or aren't lambda exprssions possible using uQuery?
Here is my code:
List dateFolders = uQuery.GetMediaByName(today.ToString("yyyy-MM-dd")).Where(x => x.ParentId == ParentFolderID).ToList();
I'm basically checked if a dated folder exists in a specific folder. The reason I perforum this check is there may be a dated folder within another folder, thats why I need to check for ParentID.
Just tried a lambda in the immediate window and get the same resposne - "Expression cannot contain lambda expressions", so it seems that it's just an issue executing within this context.
This was definitely working yesterday! but it seems now that uQuery.GetMediaByName is only searching in the root of the Media section, it can't see anything in nested folders??
Find Media "folder" by name
In a User Control - how can I find a "folder" in the media library by its name?
Hi Gordon,
If you have uComponents installed, how about:
or
HTH,
Hendy
Umm, I haven't needed to install uComponents yet ... and I'd rather not if I can avoid it.
I wanted to link a content document with a media folder by name, programmatically, rather than a content editor having to set it up. However, maybe I would be much better off (make my life easier!) if I put a Media Picker on the content node!
@Hendy
Just stumbled across this thread.
I'm currently using uComponents in my solution. When using uQuery.GetMediaByName I'm using lambda expression to check that a folders exists and if it doesn't create it.
I'm trying to debug this in VS but I'm getting an error message "Expression cannot contain lambda expressions". Forgive the stupid question but is this VS Immediate Window being rubbish or aren't lambda exprssions possible using uQuery?
Here is my code:
I'm basically checked if a dated folder exists in a specific folder. The reason I perforum this check is there may be a dated folder within another folder, thats why I need to check for ParentID.
Any help appreciated
Ben
Hi Ben,
Yes, uQuery returns collecitons so should work with Linq and lambdas - your code snippet looks valid to me (assuming today, and ParentFolderID exist):
Just tried a lambda in the immediate window and get the same resposne - "Expression cannot contain lambda expressions", so it seems that it's just an issue executing within this context.
HTH,
Hendy
Ok, cool. Makes sense.
I've got another query....have you ever experience the GetMediaByName functionality intermittently not return anything?
Here is the full code block
This was definitely working yesterday! but it seems now that uQuery.GetMediaByName is only searching in the root of the Media section, it can't see anything in nested folders??
The umbraco.log.add is for my debugging purposes.
Thanks
is working on a reply...