SubSonic generation of tables with columns as ColumnX - subsonic

This doesn't make much sense to me. We had this happen twice recently when generating SubSonic objects for a database table or view columns got renamed to ColumnX. The first time it made sense because the column name is Value, a C# keyword. But the second time it happened, the table's column name is Grade, which is not a keyword or reserved word. Does anyone know why SubSonic turns this column name into GradeX when it generates objects?
Thanks.

It is, like you assumed, to replace words so they don't conflict with .Net or SQL types. Don't forget SubSonic talks to various db providers so although "Grade" isn't a MSSQL type it's possible it's an Oracle or MySQL etc...
Under SubSonic.Utilities.Utility is a method named KeyWordCheck which does the appending.
Perhaps you can compile your own version and amend this method to exclude "Grade":
public static string KeyWordCheck(string word, string table, DataProvider provider)
{
string appendWith = "X";
if (provider.AppendWith != string.Empty)
appendWith = provider.AppendWith;
return KeyWordCheck(word, table, appendWith);
}

Related

Can I use any other column name than id in my xamarin forms app?

As the title suggest, I was wondering if it was possible to use any other column name for the index than id?
The documentation for creating a Mobile Backend in Azure and Xamarin Forms app stipulates that the index column must be id all lower case for the API to return data. What if your index column is called something else, for example idx_index.
My issue is that my database already exists and there are a lot of tables. I'd like to avoid having to rename the index columns in the database if I can.
Is there anything I can do that would help me avoid this problem or does it look like I'll need to rename my columns to id?
No - you cannot use any other name other than id. This is in-built into the SDK and you would need to alter both the server and client SDKs (and compile new ones) to support something else. This is a non-trivial update.
Since my database already existed all the column naming was set. To get around this problem when it came to Azure and it's expectation of a column called id I simply cast the column names in some custom views which were specific to my mobile app. For example:
SELECT index_idx as id,
name,
location
FROM mytable

How does CRM 2011 auto-wire the StringMapBase table in for Option List picks in Advanced Finds?

The StringMapBase SQL table is the table that holds Option List values that have been added to an entity. When using an Advanced Find in CRM 2011, if you select a pick list column (Option List) value from an entity to be added to the resultset, the Advanced Find mechanism somehow auto-wires in the string value of the pick list from the StringMapBase table instead of showing the StringMapBase's Primary Key value that's actually stored on the record.
I'm in the process of creating SSRS reports that hinge on some Option List values:
// SQL psuedocode
Select...
...
Where Value = 'Some String Value of Interest'
However, I very much dislike the fact that, so far, it looks like I basically have to write in some ad-hoc SQL in order to get the applicable StringMapBase value. In order to do so, I have to hard-code some magic values, which I despise.
Does anyone know by what mechanism the CRM Advanced Find engine auto-wires these values in? Or does it simply do its own join to the StringMap system view or use a SPROC somewhere?
When you use the Filtered views (the only supported way to read data in your report) there will be an additional "logical" column for Bit, Picklist, and Lookup columns. For an attribute named "new_option" you should be able to add "name" to the end of the column name and query "new_optionname".
select new_option, -- Integer
new_optionname -- StringMap joins generated by Filtered Views
from Filterednew_test

Copy Column Data - Azure Table Storage

So Azure Table Storage has three default member properties for its TableServiceEntity class, one of which is Timestamp. After release to Production, we now realize we need a CreatedDateTime property instead of Timestamp b/c we have no control over the Timestamp value, which acts more like a "Last Modified" value rather than "Created Date" value.
How can I copy the value in Timestamp currently over to my new property? In SQL, this seems pretty straightforward, but the cloud is a different animal. Thanks.
In Table Storage you have no schema. In a single "table" you can have 10 rows with a C# defined class of Person and 10 rows of class Dog with COMPLETELY different properties.
The reason I am saying this is because there is no schema, so the easiest thing to do would be to "re-insert" the rows as a batch with the new column/property added to the class. You can also do an UPSERT as well:
http://blogs.msdn.com/b/windowsazurestorage/archive/2011/09/15/windows-azure-tables-introducing-upsert-and-query-projection.aspx
If the column is already defined then its easy and u would just do an update, but it sounds like that new column does not exist on the previous rows entered.
If you are using a class, just add the new field for the create date time. Pull all the data down and copy the timestamp to the new field and then call update on the row. If you are already doing inserts and deletes and thigns, should be pretty straightforward.

Adding Column Using Subsonic 3.0.0.5 Migration

I want to know that How to Insert New Columns to an existing database Table using Subsonic 3.0.0.5 MIGRATIONS.
Basically I want to alter an existing table in MS SqlServer database and add three more columns into it.
Please tell me How I will be able to do it
Regards,
Naveed Khan
Just change your object and the column will be added/updated whatever. So if you have an object called "Post" and add a property, it will be added as a column in the DB.
See this video...
http://subsonicproject.com/docs/Simple_Repo_5_Minute_Demo
It has to do with the conventions of SubSonic.
As the object is singular, it adds the plural to the table (or expects the table to be plural).
So it will expect an object called Order to map to a table called Orders.
There is only two solutions that I can see for you
1) Rename you table to the plural name.
2) Modify Subsonic code to remove the adding of the plural.

SharePoint list.items.GetDataTable column names not match field names

I am binding an SPGridView to a SPList. As code samples suggest, I am using the following code to create a dataview based on the list.
dim data as DataView = myList.Items.GetDataTable.DefaultView
grid.DataSource = data
etc...
What I am finding is that the column names in the resulting dataview do not always match the source fields defined in the SPList. For example I have columns named
Description
ReportItem
ReportStatus
these show up in the resulting dataview with column names like
ReportType0
ReportStatus1
This leads me to think that I have duplicate field names defined, but that does not seem to be the case.
Seems like I am missing something fundamental here?
Thanks.
The GetDataTable method is returning the internalName (or staticName -- I can't remember for sure which but they are frequently the same) representation of the columns, rather than the Title representation, which is what you see in the Web interface. I believe GetDataTable does a CAML query under the covers, and you have to use that internalName for field references in CAML.
This blog talks about it in a little more detail.
So I posted about this on my blog, but I wrote a little utility method that you can use, right after you get the data table it basically remaps the column names in the DataTable to their friendly names.
DataTable table = list.GetItems(list.DefaultView).GetDataTable();
foreach(DataColumn column in table.Columns)
{
column.ColumnName = list.Fields.GetFieldByInternalName(column.ColumnName).Title;
}
Hope that helps!
What you also could do (if you´re using .NET 3.5) is to use an anonymous type and bind against that. If you´re doing this you might wanna go with a Linq DataSource as well.
I have made a post that explains this here.

Resources