I have business objects that implement IEnumerable and I and need to use them as datasource of a ComponentOne report. But, the "myreport.DataSource.Recordset" is only accepting a DataTable.
Could I have some help to find how can a C1Report datasource be fed with IEnumerable BOs ?
Related
I'm using CodeFluent Entities to manage my database for a ASPNET MVC3 web application. I would like to find a way to configure a Property of an Entity in my Model which would be 'transparently' managed with EncryptByPassPhrase and DecryptByPassPhrase TSQL functions.
Example TSQL INSERT/UPDATE (property 'Text') :
-> Add a #PassPhrase(?) parameter to send my key string
-> replace '#Text' by 'EncryptByPassPhrase(#PassPhrase,#Text)
Example TSQL LOAD/SEARCH (property 'Text') :
-> Add a #PassPhrase(?) parameter to send my key string
-> replace '#Text' by 'DecryptByPassPhrase(#PassPhrase,#Text)
Basically, I want to save an encrypted data (from a clear text) and retrieve a decrypted data (from the encrypted field value), without writing stored procedure on my own.
I know I can solve my problem it by creating a custom SQL Stored Procedure for both Save() and Load*() methods, but it seems to me that a tool like CodeFluent Entities might provide a way to feed my needs.
Thanks to anyone that can help me on that ;)
Before anything is actually generated, CodeFluent Entities parses the model and transforms it into a complete memory representation which contains Entities, Properties, Methods, Tables, Columns, Procedures, etc. The inference engine that does this transformation is using a pipeline that’s divided into steps. CodeFluent Entities Aspects can be introduced at any step, and are able to modify the model currently in memory, therefore influencing the next steps.
How to write an aspect is too long to be explained on SO.
You’ll find my complete answer at: http://blog.codefluententities.com/2013/09/25/writing-a-custom-codefluent-entities-aspect-to-encrypt-decrypt-columns-values-at-runtime/
I have a question about how to do data filtering with RequestFactory in GWT. I am currently working on an application which is backed by a MySQL database. My persistence layer is based on JPA/Hibernate. I am using RequestFactory to query my database for all my listing-related operations.
So for example, I have a Person object : In my PersonRequestContext I have a method which allows me to list persons. The method signature is :
Request<List<PersonProxy>> listPersons(Integer firstResult, Integer maxResults);
As you may have guessed, the corresponding query is something like this :
entityManager.createQuery("SELECT p FROM Person p ORDER BY p.id").setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
Now, I would like to filter the result based on table columns. So I wanted to use some kind of Filter class abstraction to solve it. The problem is that as we all know, it's not possible to pass non-primitive objects in to the requestFactory method.
Have you ever experienced this kind of thing ? And how did you deal with it to solve the problem?
Your assertion that only primitive types can be passed to a Request method is incorrect. See the documentation on transportable types. You can create a ValueProxy hierarchy to model your filters.
I have an entity bean that will represent an expected result over multiple databases/datasources and can also be different queries executed, but same result always comming back. So the bean is re-used over different datasources that should be able to be dynamicly selected.
Is it possible with JPA to select during runtime the data source to be used to execute a query, and return the same type of entity bean?
Also, does my ejb/application need to define the datasources that will be used? Or can I always specify via jndi what datasource to use? Modifying the descriptor's and re-deploying an application everytime a new datasource is created is not an option.
Sorry if the question does not make 100% sense, rather difficult to get the idea through.
Is it possible with JPA to select during runtime the data source to be used to execute a query, and return the same type of entity bean?
You can't change the datasource of a persistence unit at runtime. However, you can configure several persistence unit and use one or another EntityManagerFactory. Maybe JPA is not the right tool for your use case.
Modifying the descriptor's and re-deploying an application everytime a new datasource is created is not an option.
And how will the application be aware of the "available datasources"?
You can change the JPA datasource at runtime, but the approach is tricky (introspection, JPA implementation specific, ...).
I've implemented my own implementation of javax.persistence.spi.PersistenceProviderwhich override the org.hibernate.ejb.HibernatePersistence and sets the datasource in both the Map and PersistenceUnitInfo of the PersistenceProvider just before creating the EntityManagerFactory. This way, my EntityManagerFactory has a datasource which has been configured at runtime. I keep my EntityManagerFactory until the application is undeployed.
You could use the same be approach and create N different EntityManagerFactory, each with its specific datasource. However keep in mind that each ÈntityManagerFactory uses a lot of memory.
I'm using JasperReports with JavaBeans (I need to print reports in a application that uses Hibernate). Now I can work out Beans collections and use them in JasperReports, but sometimes I wonder if there is a way to access bean properties without it being a collection. What I mean is that I use JRBeanCollectionSource as a source for the various subReports. Suppose I've a list of People and each of them has a Car property. Now is there a way to access directly car properties without seeing it as a collection?
You could try pulling the property out of the Bean and putting in a different DataSource like for example JRMapCollectionDataSource.
This would mean not having to deal with the whole Bean collection each time.
Here is some sample code for constructing a DataSource.
Collection<Map<String, Object>> myColl = new ArrayList<Map<String,Object>>();
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("Field1","Value1");
map1.put("Field2","Value2");
map1.put("Field3", someObject);
myColl.add(map1);
JRMapCollectionDataSource source = new JRMapCollectionDataSource(myColl);
I'm would like to use both EF and MVVM and am trying to see how they fit together. I can't find much in the way of examples so hope you guys can answer a few questions.
Let's say I have a single table in a database called Customer. I run the EF designer and get a data model.
The next step is to run some linq to get data out of the data model. Let's create a new class called CustomerRepository to do this.
Now I'm guessing the Model would call CustomerRepository.GetCustomers to get a list of customers.
Here is my question - CustomerModel has a list of customer objects that were defined by EF in the data model. How do I add validation attributes or any kind of validation to it?
There just seems to be a bit of a disconnect between EF and MVVM. I'm sure some of you have hit this before - any ideas? Any better ways of approaching this?
Cheers
Steve
The validation, the business rules, the presentation of your Customer object should live in the ViewModel that will serve as a controller or presenter for your View.
In terms of how to create that ViewModel, you have a couple of options:
Include the Model as a property of the VM, and pass the model instance into the VM's constructor. You can then expose the Customer's properties and just wire them through to the underlying Model's corresponding properties.
Generate a ViewModel using T4 templates and Reflection (or preferably Introspection) to 'read' the Model, and generate the properties that will map directly to it.
Now you can add custom validation rules to the VM, such that when the appropriate command is sent from the View you can perform your business rules, and if appropriate you can update the Model using EF's API to persist those changes back to the database...