Skip to content

Instantly share code, notes, and snippets.

@devlights
Created December 1, 2012 13:36
Show Gist options
  • Save devlights/4182265 to your computer and use it in GitHub Desktop.
Save devlights/4182265 to your computer and use it in GitHub Desktop.
[DevExpress][XPO] Session.ExecuteQuery() using a parameterized SQL query
var dataStore = new InMemoryDataStore();
var dataLayer = new SimpleDataLayer(dataStore);
using (var uow = new UnitOfWork(dataLayer))
{
var sql = "SELECT Id, Name FROM BookGenre WHERE Name = @Name";
var pNames = new string[] { "Name" };
var pValues = new object[] { "Computer" };
var dbData = uow.ExecuteQuery(sql, pNames, pValues);
var view = new XPDataView();
view.AddProperty("Id", typeof(int));
view.AddProperty("Name", typeof(string));
view.LoadData(dbData);
grdMain.ItemsSource = view;
}
@devlights
Copy link
Author

最新バージョン (v2012 vol.2.5)で、Session.GetObjectsFromQuery()にもコメントパラメータ付きのオーバーロードが追加された。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment