LeftOuterJoin with same table - don't know how to distinguish them - subsonic

I would like to make a LeftOuterJoin between one table and same table,
but dont know how to make the distinguish them...
SubSonic.SqlQuery q = new Select().
From(TABLE.Schema).
LeftOuterJoin<TABLE>();
This returns me the error:
The objects "dbo.TABLE" and "dbo.TABLE" in the FROM clause have the same exposed names. Use correlation names to distinguish them.
Then I use
SubSonic.SqlQuery q = new Select().
From(TABLE.Schema).
LeftOuterJoin("TABLE as SecondTABLE", "SecondTABLE.ID","TABLE","ID");
But this returns me the error:
System.NullReferenceException: Object reference not set to an instance of
an object.

Related

How to use EncodedObjectAsID?

I'm trying to understand get_instance_id()
and I came across this line in the documentation:
This ID can be saved in EncodedObjectAsID, and can be used to retrieve
the object instance with #GDScript.instance_from_id.
I can't seem to understand what this statement means exaclty and how to use EncodedObjectAsID, could someone please provide a working example?
The EncodedObjectAsID follows a pattern called Boxing. Boxing is where you put a primitive value, like an int, into an object. This boxed primitive can now be used in an object oriented way. For example, you can pass the boxed int to a function that only takes objects (i.e. it applies Polymorphism):
func only_takes_object(obj: Object)
only_takes_object(123) # Error
var box = EncodedObjectAsID.new()
box.object_id = 123
only_takes_object(box) # Valid
This is how parts of the editor use the EncodedObjectAsId object.
In marshalls.cpp we can see that an encoded Object may be an integer ID or the whole object. When it is flagged as only an integer ID a EncodedObjectAsID object is created. This object is then converted to a Variant.
When adding a stack variable in editor_debugger_inspector.cpp a variant with a type of object is assumed to be and converted to an EncodedObjectAsID to fetch the referenced object's id.
Here's two more links that follow a similar pattern:
array_property_edit.cpp
scene_debugger.cpp
Note that Variant can be implicitly converted to an Object and Object::cast_to() only takes Objects.
This ID can be saved in EncodedObjectAsID, and can be used to retrieve the object instance with #GDScript.instance_from_id.
This sentence should be split into two independent clauses. It should read as
"The instance ID can be saved in an EncodedObjectAsID."
"The instance ID can be used to retrieve the object instance with #GDScript.instance_from_id()."
Note: You should not store an object's id in storage memory. There is no guarantee that an object's id will remain the same after restart.

Want to know how to bind a map type column in a prepared insert statement in Cassandra with php drivers

Can someone please help me with the exact syntax to use prepared insert / update statements containing map type columns.
suppose :
UPDATE abc SET map = map + ? where id = ?
where map is the map type column,
I found an answer
Cassandra prepared statements with collections
but it just contained the syntax to generate a particular map type object rather binding.
You need to execute it as usual for prepared queries, but you need to pass Cassandra::Map object as first parameter, something like this:
$statement = $session->prepare('....')
$map = Cassandra\Type::map(Cassandra\Type::varchar(), Cassandra\Type::int())
->create('a', 1);
$id = 'something'
$session->execute($statement, array('arguments' => array($map, $id)));
You need to pass Map object because CQL's appending to the map expects another map as an argument.

Getting the values and column names of an INSERT object in the Java Cassandra Driver

I have a Insert object created as follows:
Insert insert = QueryBuilder.insertInto("demo", "users");
insert.value("name", name);
insert.value("sport", "test");
insert.value("years", 2);
insert.value("vegetarian", true);
Somewhere else in my code, I need to get the list of names and values associated with this INSERT object. When I debug the code I can see two "values" and "names" ArrayLists that contain the information I need, however they are private and I cannot access them.
While insert.getObject(0); gets the object from the values ArrayList, I can't map the value to a column name. Furthermore insert.getValues(ProtocolVersion.V4, CodecRegistry.DEFAULT_INSTANCE); seems to serialize the objects and put them into a ByteBuffer which is not desirable.
I recommend to use the PreparedStatement & BoundStatement instead of simple Insert. First, you can get better performance if you're inserting a lot of data. And second - you'll be able to get a list of variables defined in prepared statement, together with associated values

newObjectIDForEntity in NSIncrementalStore

I have started using NSIncrementalStore. When you process a fetch request, you first have to process the predicate to get your internal reference objects. Then you convert these to objectID's and then you ask the context to get the corresponding managedObjects. At least that is my interpretation of the available documentation.
let fetchedReferences : [Int] = Array(names.keys) //names represent my backingstore
var fetchedObjectIDs : [NSManagedObjectID] = []
for reference in fetchedReferences
{
fetchedObjectIDs.append(self.newObjectIDForEntity(request.entity, referenceObject: reference))
}
var fetchedObjects : [NSManagedObject] = []
for objectID in fetchedObjectIDs
{
fetchedObjects.append(context.objectWithID(objectID))
}
"newObjectIDForEntity" is also used to obtain permanent objectID's (see obtainPermanentIDsForObjects)
I want to know what "newObjectIDForEntity" does. Does it make a new instance for the same object or does it each time internally create a new object? What I mean is this: if I create a new managed object and then fetch the object, I will have called "newObjectIDForEntity" twice for the same object. Does core data now think there are 1 or 2 objects?
Does it make a new instance for the same object or does it each time internally create a new object?
newObjectIDForEntity:referenceObject: is one of two utility methods for mapping between the store's internal representation of a managed object snapshot and an NSManagedObjectID. It's inverse is referenceObjectForObjectID:. As you might guess from the name, newObjectIDForEntity:referenceObject: returns an object considered to have a retain count of 1. newObjectIDForEntity:referenceObject: calls an internal factory method for generating an NSManagedObjectID that is unique to that reference object in this persistent store. Once that has been done, referenceObjectForObjectID: can look up that NSManagedObjectID and return the reference object it represents.
What I mean is this: if I create a new managed object and then fetch the object, I will have called "newObjectIDForEntity" twice for the same object. Does core data now think there are 1 or 2 objects?
I assume you mean an NSManagedObjectContext that is using your store creates the managed object. You can call newObjectIDForEntity:referenceObject: as many times as you want, the NSManagedObjectID instance may be different, but the data it represents is unchanged. It will know that it points to the same reference object as an earlier call with the same reference data and entity description.

Subsonic 3: Strongly typed return value for stored procedures that return mixed results from different tables

Say I have a stored procedure that returns dataSet from 2 different tables. Example:
SELECT Customers.FirstName, Customers.LastName, SUM(Sales.SaleAmount) AS SalesPerCustomer
FROM Customers LEFT JOIN Sales
ON Customers.CustomerID = Sales.CustomerID
GROUP BY Customers.FirstName, Customers.LastName
Is there any way to get a strongly typed list as a result from this stored procedure ? Something like this:
StoredProcedure sp = myDevDB.GetCustomerSales();
List<MyCustomType> resultSet = sp.ExecuteTypedList<MyCustomType>();
How and where do I define the MyCustomType class ? How do I map its properties to the actual table columns ?
thanks,mehul
I solved it by creating a class (in the same place as all my other classes, but I didn't extend IActiveRecord, it's just a vanilla class).
Make sure the property names have exactly the same name and data type as the ones in the procedure, then call db.sproc(params).ExecuteTypedList().AsQueryable(); and it populated fine.

Resources