How do I join on an IQueryable? The type is unknown

I used dynamic linq to generate search results. The very last call is .Select(“UserID”), which ultimately returns an IQueryable (non-generic interface).

Now, that represents my list of users who meet search criteria.

Next, I’m trying to join those results with the original Users table so I can then join in the rest of the info associated with each user.

When I try to do this:

IQueryable<Users> users = /*assume valid instance acquired*/
/*matchingUsers is a valid IQueryable instance returned by a dynamic linq query*/
var results = users
.Join( matchingUsers, u => u.ID, m => m.UserID, (u, m) => u )

That fails trying to access m.UserID, because the type of the IQueryable is unknown. The type is accessible as a Type instance on the IQueryable via the ElementType property, but I don’t know how I can use it in this situation.

I’ve also tried the following:

private class UserIDList { public Guid UserID { get; set; } }
filteredUsersDynamicLinqQuery
.Select("new MyNamespace.UserIDList(UserID)")

but the new operator can’t seem to handle specific type names. I saw another post suggesting it could, so maybe the syntax is just wrong.

I’ve tried :

var results = users
.Join( matchingUsers.Cast<dynamic>, u => u.ID, m => m.UserID, (u, m) => u )

It’s highlighted by the compiler with error: “An expression tree may not contain a dynamic operation.”

I’ve tried:

var results = users
.Join( matchingUsers.Cast<UserIDList>(), u => u.ID, (UserIDList m) => m.UserID, (u, m) => u )

read more

How do I join on an IQueryable? The type is unknown

I used dynamic linq to generate search results. The very last call is .Select(“UserID”), which ultimately returns an IQueryable (non-generic interface).

Now, that represents my list of users who meet search criteria.

Next, I’m trying to join those results with the original Users table so I can then join in the rest of the info associated with each user.

When I try to do this:

IQueryable<Users> users = /*assume valid instance acquired*/
/*matchingUsers is a valid IQueryable instance returned by a dynamic linq query*/
var results = users
.Join( matchingUsers, u => u.ID, m => m.UserID, (u, m) => u )

That fails trying to access m.UserID, because the type of the IQueryable is unknown. The type is accessible as a Type instance on the IQueryable via the ElementType property, but I don’t know how I can use it in this situation.

I’ve also tried the following:

private class UserIDList { public Guid UserID { get; set; } }
filteredUsersDynamicLinqQuery
.Select("new MyNamespace.UserIDList(UserID)")

but the new operator can’t seem to handle specific type names. I saw another post suggesting it could, so maybe the syntax is just wrong.

I’ve tried :

var results = users
.Join( matchingUsers.Cast<dynamic>, u => u.ID, m => m.UserID, (u, m) => u )

It’s highlighted by the compiler with error: “An expression tree may not contain a dynamic operation.”

I’ve tried:

var results = users
.Join( matchingUsers.Cast<UserIDList>(), u => u.ID, (UserIDList m) => m.UserID, (u, m) => u )

read more

Get ready to meet Kudu, a new, open-source storage engine from Cloudera

An open-source storage engine called Kudu could soon be on the way from Cloudera, offering a new alternative for companies with big data stores to manage.

Kudu will be offered as an alternative to the popular Hadoop Distributed File System and the Hadoop-oriented HBase NoSQL database, according to a VentureBeat report, which cited a slide deck on Kudu’s design goals.

A small Cloudera team has reportedly been working on Kudu for the past two years. The company has already been pitching it to customers and plans to release it as Apache-licensed open-source software at the end of this month, VentureBeat said, citing a source familiar with the matter.

read more

Swift – Add Color to CGrect

I’m currently Adding a rectangle to an image in case it’s not squared “filling” the remaining space, making it square. The idea is that this is a cheap approach (in terms of time required to “force” an image to be squared).

As you can see in the image attached, the square I generate does not have a color, and this might confuse the user. This is why I’d like to add a color to the CGRect I’m generating. The problem is I’ve not found any way to do this. Any suggestions on how to give color to this square generated, would be greately appreciated.

enter image description here

enter image description here

The current code I have to do this is the following:

func forceSquaredImage(image: UIImage) -> UIImage{
    let maxDimension = max(image.size.height, image.size.width)

    var newImage : UIImage = image

    if(image.size.height > image.size.width){

        UIGraphicsBeginImageContextWithOptions(CGSize(width: maxDimension, height: maxDimension), false, 0.0);

        image.drawInRect(CGRectMake(image.size.height/2-image.size.width/2, 0, image.size.width, image.size.height))
        newImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

    }else if(image.size.height < image.size.width){

        UIGraphicsBeginImageContextWithOptions(CGSize(width: maxDimension, height: maxDimension), false, 0.0);
        image.drawInRect(CGRectMake(0, image.size.width/2-image.size.height/2, image.size.width, image.size.height))
        newImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return newImage

    }

    return newImage

}

read more