How do I know all the objects in my entity framework model programatically - entity-framework

I am trying to find out if there is a way we can iterate over all the objects in my entity framework model? I tried looking through intellisense and msdn and stackoverflow but couldn't properly identify anything that matched my query.
Something like the following ...
foreach(var item in entities.Context.getAllObjects())
{
Console.Write(item.Name);
}
The point of this is that I want to be able to write some reports over database objects for our developers and devops teams to better understand what's happening in our production servers. I've already got the data into the tables in a separate database that I want to report on. But instead of writing the specific reports that we may or may not want to see. I'd like to be able to provide some sort of interface that might list the possible report tables. Then have some options that might be group by date, dayOfWeek or Hour from this date to this date.
I don't want there to have to be application changes in order to add new reports. This is my first hurdle in writing this app ... I'm sure there'll be others. Because the application is for our development team I'm not going to worry about someone trying to query the data in a way that doesn't make sense ... and I also want there to be an absolute minimum barrier to entry as we can't write a report for everything that we want to track.
Thanks

You need something like this:
var typesInYourContext = context.GetType()
.GetProperties()
.Where(p => p.PropertyType.IsGenericType && typeof(DbSet<>).IsAssignableFrom(p.PropertyType.GetGenericTypeDefinition())
.Select(p=>p.PropertyType.GetGenericArguments()[0]);
(I havent compiled it and its off the top of my head but it should give you the general idea)
Note: EF may actually pull in more types than those listed in your context, but this will only get the ones you explicitly list in the DbContext.

Related

Azure DevOps - how to track planned vs unplanned work items

We have agile / devops culture -based teams who have a need to track work that has been planned and prioritized at an expected pace, vs work that came in for immediate handling. Some are bugs, some are tasks, some stories, etc.
We're thinking that adding a custom field is the way to go, with potential values of Maintenance and Enhancement. And of course, the hardest part: What would the field name be?
Is there a better approach? We don't think that a new work item is really it, but we could be convinced otherwise.
Additionally, we've looked at all of the canned fields and don't see an obvious field that fits, but we would prefer to use the built-in fields where it makes sense.
What, if any, is the recommended approach? I'd be very surprised if we're the first with this need.
A custom field doesn't have big difference from predefined field, so you can feel free to create one when no existing predefined fields can meet your needs.
I agree with your thought of adding a custom field. As for the field name, we can simply name it PlanStatus,PlannedOrNot or whatever you like...
You only need:
1.One inherited process based on Agile process template.
2.Edit Bug type and create the field.
Then edit other workItem types who also need this field. (Edit=>Add an existing field=>PlanStatus)
3.Then you can create a bug/epic with PlanStatus field and you can use the newly created field in Query. Besides, you can add a widget in Project OverView=>Dashboard to track the planned/unplanned workitems. (Chart for WorkItems widget or Query Results widget or what...)

CRM Dynamics trigger workflow before saving

A little background:
I have 2 entities (Product and Case). The product entity will hold all product records. A section in the Case will have the ability to choose products and auto-populate all related fields that are located in the product record for that specific product. For example, Product record has fields like hazardous, range, lot ect. The same field appear on the Case record. These fields should only be populated based on the product that was selected.
I was able to accomplish the above by creating a 1:N relationship and adding it to my Case form. I then created a workflow to populate the related fields (hazardous, range, lot ect). However, these fields only populate when the record is saved. Is there a way to make it update the fields once the product is chosen?
I want to refrain form using any type of JavaScript. If possible, I would like to strictly use workflows to accomplish this (if at all possible).
Real time information in your case can be only accomplished by using JavaScript. Maps works too but they have a special behavior.
Workflows that fire when the record is created only execute after all core operations are done (Native logic, Plug-in logic...) and you can't fire workflows if the record is not created.
So using workflows is a good idea even if you can't see the information

Options for Importing a Database & Displaying a Daily Tip

I am new to iOS programming and looking for advise for an iPhone app that I am creating.
I have an excel database of about 100 daily tips (which will continue to grow) that I want to import into the app, and have one tip display each day. The user will have access to the current daily tip, plus any prior tips from prior days in the database.
I would like to keep it as a closed app, so if a user feels they want to skip ahead to see new tips by changing their current date - I am not worried about the few who might do that.
From my searches so far, CoreData seems to be the way to go but I was looking for suggestions.
Any help is greatly appreciated.
I'll try to give you some advice to achieve what you want.
First of all, what do you mean with
I would like to keep it as a closed app, so if a user feels they want
to skip ahead to see new tips by changing their current date - I am
not worried about the few who might do that.
I'm not sure about its meaning.
Said this, based on my experience (someone else could give you other advice) I suggest you the following.
About your model you need to create an entity, say Tip, that could have the following attributes:
guid: an identifier that works as an identifier, the type could be a NSString
creation date: the creation date for your tip, the type is a NSDate
text to present: the text to present to the user, the type is a NSString
In addition you can also set a title, etc.
The date has two objectives.
First, it allows you to filter tips based on the current date. To filter you need to create a NSFetchRequest and set a NSPredicate. For example:
[NSPredicate perdicateWithFormat:#"creationDate <= %#", currentDate];
In addition it allows to sync with your service to download data. Based on the max date you find in the core data sql lite file, you could ask a service (if you use one) to give you the tips that are greater than that date.
The guid allows to have only one tip for that identifier (you could just use the date for that but I think is easier to have a guid, say 12345). This could be useful if you decide to download each time the whole data and you don't want to insert the same tips. In addition, you don't want to ricreate the db when you have new tips, but you would add only the new ones. So, you need an identifier that let you to verify if a tip is already there.
Finally, about your service (if you want to set up one) you could download data in JSON format. I think it's simply to set up.
If you are interested, here some links that could make your life easier:
Take a look at importing-and-displaying-large-data-sets-in-core-data in the case the data amount of downloaded data is huge. With iOS 5 new APIs are there, but the concepts you find in the post still remain valid.
A simple intro on Core Data (a question I answered in a previous post)
core-data-on-ios-5-tutorial-getting-started
If you want to know something else, let me know.
Hope it helps.

CRM 2011 and SSRS - Generating a report for a single record

Is it at all possible using CRM 2011 and SSRS to generate a report on a single record, and only get results for that one record?
EDIT
Additional Info - Must Use:
Custom SSRS report
Custom entity in CRM
Here's a more specific link to your question: link. You're probably looking for pre-filtering (look for "3. Pre-filtering Element" in the link provided) if you want the report to be record specific (context sensitive).
Here's a link describing the 2 types of pre-filters (CRM 4.0 but the theory applies to CRM 2011): link. And here's an example of prefiltering in CRM 2011: link
I have done this successfully in CRM 2011 with a completely custom report made in BIDS, on a custom entity, with full context sensitivity.
Make sure to learn fetchXML as it's going to be the going forward technology for these reports. The existing reports are using SQL which make them bad examples to copy off of.
Here's an example on how to extract fetchXML from an advanced find: link It also has more information on pre-filtering.
Take a look a the report Account Overview.rdl. It could be executed for a single account record or multiple records.
See Reporting for Microsoft Dynamics CRM Using Microsoft SQL Server Reporting Services
Create an embedded connection to the CRM database engine for the environment you want to target.
Create an embedded dataset to query the current record. This going to be kind of weird since experience will tell you that you are going to get tons of records, but because of the clunkiness behind CRM it will actually only get the current record. For example, if you wanted to get the current quote you would use "SELECT quoteid FROM FilteredQuote AS CRMAF_Quote"
Add a parameter to store the reference to the entity you just queried. In keeping with this example I created #QuoteFilter which is type text, could store multiple values (even though that's not what we're using it for), and gets its default value from the dataset in step 2. Also, probably ought to make this hidden since GUIDs aren't end user friendly.
Finally, use the parameter discovered in the where clause of the other datasets. For example, a search on quote products for the current quote would look something like SELECT * FROM FilteredQuoteDetail WHERE (quoteid = #QuoteFilter)
As a final note, you should keep in mind that CRM loves to remember everything even when you don't want it, too. On one of my reports I messed up my datasource and CRM was forever convinced that the report should run against all records. I fixed my datasource, but uploading the report did not trigger a refresh and correct the problem. In the end, I deleted the report from CRM, created a new one, uploaded the same exact file with no changes, and everything worked. Go figure.

Eclipse Birt Reports, Creating report from SQL database, (user key?)

I'm fairly new to using the Birt Report Designer and need to figure out how to generate a report from a SQLite database. I have suceeded in getting it to connect to the DB but am now unsure how to generate a report and the tutorials that I have found aren't of much help so far.
I have a template that was given to me by my employer that has a few fields, I'm wondering if these fieldnames (in the template) are supposed to match field names in the DB.
Also, when I go to Run->View Report-> As PDF I am unsure what I am supposed to enter for the field "User Key", does this correspond to a table name in the DB or something along these lines?
As of now, I have tried entering a table name but just a blank report is generated.
If anyone can point me to a good resource or help with this I would greatly appreciate it. Thanks
There are two books i could really advice:
BIRT - A Field Guide to Reporting
Integrating and Extending BIRT
and the Eclipse Help containing BIRT documentation.
I suppose the User Key could be report parameter (listed in Data Explorer window), which is passed to Data Set to select appropriate data. If I'm guessing right, check within a Data Set editor ("Parameters" tab and "Query" tab) where the User Key parameter goes in - probably to one of the table field in a WHERE clause. Parameters in a query are represented by question marks: SELECT * FROM fooTable WHERE barColumn = ?. Hope tracking this would lead to find out, what to enter to the parameter.
Additionally, ensure if your Data Set(s) is(are) connected correctly to your SQLite Data Source ("Data Source" tab in a Data Set editor).
Being as new as you are to BIRT, I would suggest building a couple of reports with the sample DB (Classic Models). There are many, many samples out there for you to use as a guide. Additionally, most tutorials will use the Classic Models data so you can follow right along. After you create a couple of practice reports (this should not take more than 30-45 minutes) the template you have been given will likely make A LOT more sense and allow you to make progress almost immediately.
If you are looking for a nice collection of tutorials and samples, be sure to check out Birt Exchange for Dev Share (samples) & tutorials.
As for the "User Key" this is almost certainly a report-level parameter used to filter the data set (as the previous answer points out).
Good Luck!