.net - Come filtrare e combinare 2 set di dati in C #

original title: ".net - How to filter and combine 2 datasets in C#"


I am building a web page to show a customer what software they purchased and to give them a link to download said software. Unfortunately, the data on what was purchased and the download information are in separate databases so I can't just take care of it with joins in an SQL query.

The common item is SKU. I'll be pulling a list of SKUs from the customer purchases database and on the download table is a comma delineated list of SKUs associated with that download. My intention, at the moment, is to create from this one datatable to populate a GridView.

Any suggestions on how to do this efficiently would be appreciated. If it helps, I can pretty easily pull back the data as a DataSet or a DataReader, if either one would be better for this purpose.

Sto costruendo una pagina web per mostrare a un cliente quale software ha acquistato e per fornire loro un link per scaricare detto software. Sfortunatamente, i dati su ciò che è stato acquistato e le informazioni di download ...

Questo è il riepilogo dopo la traduzione, se è necessario visualizzare la traduzione completa, fare clic sull'icona "traduci"

Tutte le risposte
  • Translate

    As long as the two databases are on the same physical server (assuming MSSQL) and the username/password being used in the connection string has rights to both DBs, then you should be able to perform a join across the two databases. Example:

    select p.Date,
    from   PurchaseDB.dbo.Purchases as p
    join   ProductDB.dbo.Products as d on d.sku = p.sku
    where  p.UserID = 12345

  • Translate

    Why not create a Domain object based approach to this problem:

    public class CustomerDownloadInfo
        private string sku;
        private readonly ICustomer customer;
        public CustomerDownloadInfo(ICustomer Customer){
            customer = Customer;
        public void AttachSku(string Sku){
            sku = Sku;
        public string Sku{
            get { return sku; }
        public string Link{
                // etc... etc...          

    There are a million variations on this, but once you aggregate this information, wouldn't it be easier to present?

  • Translate

    I am thinking off the top of my head here. If you load both as Data Tables in the same Data Sets, and define a relation between the two over SKU, and then run a query on the Data Set which produces the desired result.