我们正在搜索将List& Label Drilldowns集成到报告中的文档。
官方文件在我看来真的很糟糕。我们从他们的支持中获得了一些代码片段,但只有非类型化数据且没有任何评论。
object[] restrictions = new Object[] { null, null, null, "TABLE" };
DataTable table = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, restrictions);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(new OleDbCommand("SELECT * FROM [" + tableName + "] WHERE OrderID > 11040", onn));
object[] restrictions1 = new Object[] { null, null, null, null };
DataTable table1 = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Foreign_Keys, restrictions1);
ds.Relations.Add(new DataRelation(relationName, ds.Tables[parentTable].Columns[parentCol], ds.Tables[childTable].Columns[childCol]));
我们不知道为什么他们在这里使用了一个null对象数组,以及如何根据请求生成IEnumerable<MyClass>
的报告。最后这没有帮助,我们仍然在搜索如何通过钻取数据传递带有数据的报告。
也许有人可以在这里提供帮助并提供一些最佳实践经验吗?
答案 0 :(得分:1)
您粘贴的代码段不是LL特定的,而是通过ADO.NET解析表和关系的通用方法。假设你有IEnumerable<Customer>
其中Customer类是按
class Customer
{
//Constructor
public Customer(int customerID, string companyName, string contactName, string address, string city)
{
CustomerID = customerID;
CompanyName = companyName;
ContactName = contactName;
Address = address;
City = city;
OrderList = new List<Order>();
}
public List<Order> OrderList { get; set; }
// The CustomerID should not be available in the designer
[Browsable(false)]
public int CustomerID { get; set; }
public string CompanyName { get; set; }
// Set display name, which should be used in the designer
[DisplayName("Name")]
public string ContactName { get; set; }
public string Address { get; set; }
public string City { get; set; }
}
// The "Order" class represents a single order of a customer
class Order
{
//Constructor
public Order(int orderID, DateTime orderDate, string shipName, string shipCountry, double price)
{
OrderID = orderID;
OrderDate = orderDate;
ShipName = shipName;
ShipCountry = shipCountry;
Price = price;
}
public int OrderID { get; set; }
public DateTime OrderDate { get; set; }
public string ShipName { get; set; }
public string ShipCountry { get; set; }
public double Price { get; set; }
// Explicitly set a barcode field type
[FieldType(LlFieldType.Barcode_EAN128)]
public string PriceEan
{
get { return Price.ToString(); }
}
}
你通常要做的就是
using (ListLabel LL = new ListLabel())
{
LL.DataSource = MyCustomerList;
LL.Design();
}
这将为您提供所有功能,包括从Customer
到Order
课程的深入分析等。我还添加了可用属性的示例来微调结果。