Created
December 1, 2012 09:39
-
-
Save devlights/4181320 to your computer and use it in GitHub Desktop.
XPDataView.FillProperties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DevExpress.Xpo; | |
namespace DevExpress.Xpo | |
{ | |
public static class XPDataViewExtensions | |
{ | |
// | |
// [usage] | |
// var view = new XPDataView(); | |
// var selectData = uow.ExecuteQueryWithMetaData(sql); | |
// | |
// view.FillProperties(selectData.ResultSet[0]) | |
// .LoadData(new SelectedData(selectData.ResultSet[1]); | |
// | |
public static XPDataView FillProperties(this XPDataView self, SelectStatementResult schemaResult) | |
{ | |
foreach (var row in schemaResult.Rows) | |
{ | |
var propName = row.Values[0] as string; | |
var propType = DBColumn.GetType((DBColumnType)Enum.Parse(typeof(DBColumnType), row.Values[2] as string)); | |
self.AddProperty(propName, propType); | |
} | |
return self; | |
} | |
// | |
// [usage] | |
// new XPDataView().FillAndLoad(uow.ExecuteQueryWithMetaData(sql, names, values).ResultSet); | |
// | |
public static XPDataView FillAndLoad(this XPDataView self, SelectStatementResult[] results) | |
{ | |
self.FillProperties(results[0]) | |
.LoadData(new SelectedData(results[1])); | |
return self; | |
} | |
// | |
// [usage] | |
// new XPDataView().FillAndLoad(sess, sql); | |
// | |
public static XPDataView FillAndLoad(this XPDataView self, Session sess, string sql) | |
{ | |
return self.FillAndLoad(sess.ExecuteQueryWithMetadata(sql).ResultSet); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment