问题描述:

I am creating classes for generating queries for various tables. each table have its own class . A class for the table called MetaTable looks like this

public class MetaTableQueryCreator

{

public int userID { get; set; }

public int CategoryID { get; set; }

public string Tags { get; set; }

public string FilePath_Pk {get;set;}

public MetaTableQueryCreator()

{

userID = 0;

CategoryID = -1;

Tags = string.Empty;

}

public string GetInsertQuery()

{

string query = string.Empty;

if(!String.IsNullOrEmpty(FilePath_Pk))

{

// query = @"INSERT INTO MetaTable VALUES('" + userId + "', 1,'','','','','','','" + input + "','','','')";

}

else

{

}

return query;

}

public string GetDeleteQuery()

{

string query = string.Empty;

if (!String.IsNullOrEmpty(FilePath_Pk))

{

// query = @"INSERT INTO MetaTable VALUES('" + userId + "', 1,'','','','','','','" + input + "','','','')";

}

return query;

}

public string GetUpdateQuery()

{

string query = string.Empty;

if (!String.IsNullOrEmpty(FilePath_Pk))

{

//query = @"INSERT INTO MetaTable VALUES('" + userId + "', 1,'','','','','','','" + input + "','','','')";

}

return query;

}

}

I am using MEF in my application, so i need to create a base class for all these Query generator classes. I need to solve the following problem while creating the base class

1) I am having properties corresponding the fields in the table in each class. For each class it will have a separate set of properties(corresponding the fields), so that i cannot put all these properties in the base class, since i am using the MEF i only have access to the properties defined in the base class in my main program. How can i solve this problem? Is there any better architecture for this problem?

相关阅读:
Top