| Author |
Message |
jimmypooh
Joined: 12 Oct 2010 Posts: 8
|
Posted: Fri Oct 15, 2010 7:40 pm Post subject: Missing Field from Where Clause |
|
|
I'm using the compaire and passing it a where clause for each mapping. However, not all tabled have the field I'm using in the where clause. Is there a way to tell the comparer to ignore the where clause if it errors?
Or I guess the better question is how do I check the TableMapping if that particular where clause will be viable (ie if a certain field exists). |
|
| Back to top |
|
 |
james.billings
Joined: 16 Jun 2010 Posts: 864 Location: My desk.
|
Posted: Mon Oct 18, 2010 1:34 pm Post subject: |
|
|
Thanks for your query.
There isn't a particularly quick way of doing this, but one option is as below:
| Code: |
private static void AddWhereClause(TableMappings mappings)
{
foreach (TableMapping mapping in mappings)
{
if (mapping.Obj1.FullyQualifiedName=="[dbo].[ActionHistory]")
{
foreach (FieldMapping m in mapping.FieldMappings)
{
if (m.Obj1.Name == "ActionDate")
{
mapping.Include = true;
mapping.Where = new WhereClause("RecordID>=2");
}
}
}
else
{
mapping.Include = false;
}
}
}
|
In this instance, as I iterate around the mappings collection I'm checking for a certain table name. Within that check, I'm going through the fields collection to then see if a specific column exists.
You can perhaps tweak this so the column or table level check looks at your where clause to automate it to a certain extent.
Hope that helps. |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group