- private agsEntities agsEntities = new agsEntities(connectionstring);
- public ObservableCollection<FAMILY> FamilyCollection.....
- ..........INotify
- public ObjectQuery<FAMILY> FamiliesQuery;
- // FAMILY class is defined as: public partial class FAMILY : EntityObject
- // mostly this was autocreated by EF
- public ObjectQuery<FAMILY> GetFAMILIESQuery(agsEntities agsEntities)
- {
- ObjectQuery<FAMILY> fAMILIESQuery = agsEntities.FAMILIES;
- return fAMILIESQuery;
- }
- private CollectionViewSource _familiesViewSource;
- public CollectionViewSource FamiliesViewSource
- {
- get
- {
- if (_familiesViewSource == null)
- GetFamilyViewSource();
- return _familiesViewSource;
- }
- }
- private void GetFamilyViewSource()
- {
- // Load data into FAMILIES
- //this is ObjectQuery<T>
- this.FamiliesQuery = this.GetFAMILIESQuery(this.agsEntities);
- //this is a CollectionViewSource......
- this._familiesViewSource = new CollectionViewSource();
- //this is an ObjectResult<T>
- this._familiesViewSource.Source = this.FamiliesQuery.Execute(MergeOption.AppendOnly);
- //refresh the view (in this case a DataGrid is bound to FamiliesViewSource
- this._familiesViewSource.View.Refresh();
- //and into an observable collection just in case
- //agsEntities.FAMILIES is defined by EF as: public ObjectSet<FAMILY> FAMILIES
- foreach (FAMILY thing in agsEntities.FAMILIES)
- FamilyCollection.Add(thing);
- }
FileTime
Saturday, September 6, 2014
Some overview of Entity Framework implementation
Friday, September 5, 2014
Installing/Using Entity Framework on Visual Studio 2010 with NPGSQL DDEXprovider extension
Win 7 - 64 bit
Visual Studio 2010 Ultimate SP1
.NET 4.0 only.
Entity Framework 6.1.30610.0, NpgSQL version 2.2.0.0 , also includes Mono.Security.
http://www.mediafire.com/download/b6nti9axr0302i6/NpgSQL-EF.rar
DDEX Provider Extension ( plugin / add-in ) for VS 2010 only (none other)
- adds PostgreSQL to the Add Item | Create ADO.NET Entity Data Model menu.
http://www.mediafire.com/download/c55qcsocoqktq5t/NpgsqlDdexProvider.rar
GACUtil
http://www.mediafire.com/download/33mfozceo9gh6jl/gacutil.rar
Step 1: Extract the files from the DLL. Copy Npgsql.dll and Mono.Security.dll to an important system folder, like program files or windows, because they will be going in the system-wide GAC (Global Assembly Cache) and you dont want to delete them by accident if you had them in Downloads\stupidname.
Step 2:
RunVisual Studio 2010 as Administrator, click "Tools | Visual Studio Command Prompt" (this launches an elevated / admin command prompt, WITH the proper PATH Variables to find gacutil. If you cannot find gacutil, I have provided it, it is also located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\
Make sure you point it to the right path- take note that program files is administrator only. Run the following command to Install to the GAC.
gacutil -i "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Npgsql40\Npgsql.dll"
gacutil -i "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Npgsql40\Mono.Security.dll"
Search for <DbProviderFactories> inside <system.data> and add the following line. Take note that the existing entry has a closing </DbProviderFactories> tag on the end of the line. You must add it before this. Formatting it with Enter, Tabs, and spaces are ok, like XML code.
Step 5:
Open your visual studio solution / project that you want to use. Right click "Add references" and locate and add 4 of the 6 DLL files you extracted from NpgSQL-EF.rar (Mono.Security is not needed, Legacy is not needed) - so you need these 4: EntityFramework.dll , EntityFramework.SqlServer.dll , Npgsql.dll , Npgsql.EntityFramework.dll
Step 6:
A new file named "App.config" was created at the bottom of your project. Locate the <providers> section and add this provider:
Step 7:
Step 8:
Right Click your PROJECT itself in solution explorer.
Add -> New Item...
ADO.NET Entity Data Model
Now, Follow these nice Instructions made for 2013, the first picture has 4 icons instead of 2, so you want to:
"Generate From Database"
https://github.com/npgsql/Npgsql/wiki/Visual-Studio-Design-Time-Support---DDEX-Provider#new-adonet-entity-data-model
(Where I got the procedure from - written for 2013: https://github.com/npgsql/Npgsql/wiki/Visual-Studio-Design-Time-Support---DDEX-Provider )
It took me a very long time to figure this out, alot of errors, I couldnt find the extension, I needed to compile it myself, and I needed Visual Studio 2010 SP1 SDK to do it.
Visual Studio 2010 Ultimate SP1
.NET 4.0 only.
Entity Framework 6.1.30610.0, NpgSQL version 2.2.0.0 , also includes Mono.Security.
http://www.mediafire.com/download/b6nti9axr0302i6/NpgSQL-EF.rar
DDEX Provider Extension ( plugin / add-in ) for VS 2010 only (none other)
- adds PostgreSQL to the Add Item | Create ADO.NET Entity Data Model menu.
http://www.mediafire.com/download/c55qcsocoqktq5t/NpgsqlDdexProvider.rar
GACUtil
http://www.mediafire.com/download/33mfozceo9gh6jl/gacutil.rar
Step 1: Extract the files from the DLL. Copy Npgsql.dll and Mono.Security.dll to an important system folder, like program files or windows, because they will be going in the system-wide GAC (Global Assembly Cache) and you dont want to delete them by accident if you had them in Downloads\stupidname.
Step 2:
RunVisual Studio 2010 as Administrator, click "Tools | Visual Studio Command Prompt" (this launches an elevated / admin command prompt, WITH the proper PATH Variables to find gacutil. If you cannot find gacutil, I have provided it, it is also located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\
Make sure you point it to the right path- take note that program files is administrator only. Run the following command to Install to the GAC.
gacutil -i "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Npgsql40\Npgsql.dll"
gacutil -i "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Npgsql40\Mono.Security.dll"
Step 3:
Extract NpgsqlDdexProvider.rar anywhere and Double Click the NpgsqlDdexProvider.vsix file (in to load the provider into the menu)
Step 4:
In the same Admin Command Prompt, run notepad.exe and edit the machine.config (needs admin)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
Search for <DbProviderFactories> inside <system.data> and add the following line. Take note that the existing entry has a closing </DbProviderFactories> tag on the end of the line. You must add it before this. Formatting it with Enter, Tabs, and spaces are ok, like XML code.
<add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
For example, This is the way it is written on my own computer:
<system.data><DbProviderFactories><add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/><add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" /></DbProviderFactories></system.data>
Step 5:
Open your visual studio solution / project that you want to use. Right click "Add references" and locate and add 4 of the 6 DLL files you extracted from NpgSQL-EF.rar (Mono.Security is not needed, Legacy is not needed) - so you need these 4: EntityFramework.dll , EntityFramework.SqlServer.dll , Npgsql.dll , Npgsql.EntityFramework.dll
Step 6:
A new file named "App.config" was created at the bottom of your project. Locate the <providers> section and add this provider:
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
If you need to use legacy, for some reason, add:<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFrameworkLegacy" />
Step 7:
Re-Build your project. "Build menu | Rebuild"
Step 8:
Right Click your PROJECT itself in solution explorer.
Add -> New Item...
ADO.NET Entity Data Model
Now, Follow these nice Instructions made for 2013, the first picture has 4 icons instead of 2, so you want to:
"Generate From Database"
https://github.com/npgsql/Npgsql/wiki/Visual-Studio-Design-Time-Support---DDEX-Provider#new-adonet-entity-data-model
(Where I got the procedure from - written for 2013: https://github.com/npgsql/Npgsql/wiki/Visual-Studio-Design-Time-Support---DDEX-Provider )
It took me a very long time to figure this out, alot of errors, I couldnt find the extension, I needed to compile it myself, and I needed Visual Studio 2010 SP1 SDK to do it.
Saturday, August 23, 2014
FileTime 1.0
Download FileTime version 1.0
FileTime, v1.0 - Can modify folder and file timestamps in bulk / recursively.
Feature: Bulk timestamp modification based on rules.
Background:
When you copy files with windows, it changes the dates of files to the time you copied it. But the "Modification" date is still intact. The folder dates however are completely changed, and with this program, you can bulk fix them based on the rule you choose. (usually using the intact file modification time to fix the 3 wrong dates on the parent folder. For file moves, the situation is a bit better, only the date accessed gets messed up (IMO the least useful of the three). For folder moves, oddly, the folder creation date is the only one that remains intact.
Mode 1: Standard
Mode 2: Set Folder timestamps based on the files inside.
Created completely in C#, and .NET 2.0 using Visual Studio 2010 (WinForms).
Source is available upon request.
Authored by genBTC.
Date: August 24, 2014
How to Use:
Mode 1: Standard Mode
Take note of the "Recurse" checkbox, and "Perform on files" checkbox.
Starts at the root folder, works its way down(deeper).
Mode 2: Recursively Set Folders based on Files/Dirs Inside
Starts at the root folder, inspects whats inside, decides what to use as the time source (either file or subdir), oldest/newest/random file, and which attribute (or any/random) based on what radiobuttons are used. Then sets the date of the root folder on what is in the root folder. Then it recursively digs deeper and repeats the same process for any/all subdirectorys. Does not change dates of any files.
After clicking the "Update" button, in either mode, a second "Confirm" window will open up.
This confirm window is an essential part of the program, where you can double check what exactly will be done, remove from, add to, change date/times, and open Windows Explorer.
The confirm window has a choice of "Update if date is newer/older/always" - a filter mask, that applies once you click the final "Confirm" button.
Behavior/Quirks:
-From Currently Selected cannot be selected if nothing on the right side is selected.
-To unselect something (since Ctrl click doesnt work) on the right side, there is a small blank empty space next to the scrollbar that you can click. (Outside of the first column).
-On the confirm window, there is an issue where selecting items will cause the checkboxes to change. I built in a protection circuit that will prevent this (to make it seem normal) but you will find that if you try to change the checkboxes within 800ms of selecting something, it won't let you. The other side of this means that if you manage to hold the mouse button down for more than 800ms between when you select something and when you let go, you will bypass the protection and the checkbox will change. I have not found a better solution for this, as it is inherent in the ListView control for WinForms.
A Side Note on Read Only Folders:
-Read only folders are actually not what you think they are. Windows uses the folder read-only flag for internal purposes. The checkbox in the Windows Explorer Properties window of a user folder serves only one purpose, it is there to allow a user to change the read-only status of All the sub-files inside the folder at once. It _is_ possible to change the folder read-only flag to "not read-only" (with attrib -r) but absolutely nothing is gained by doing this. This confusing checkbox is not to be confused with PERMISSIONS. For further reading It is not recommended to change the read-only flag on folders such as C:\Windows\Fonts, because it literally is what makes the special custom view be displayed. This program should still modify Timestamps of read-only FOLDERS but not read-only files (unless it is desired/set).
FileTime, v1.0 - Can modify folder and file timestamps in bulk / recursively.
Feature: Bulk timestamp modification based on rules.
Background:
When you copy files with windows, it changes the dates of files to the time you copied it. But the "Modification" date is still intact. The folder dates however are completely changed, and with this program, you can bulk fix them based on the rule you choose. (usually using the intact file modification time to fix the 3 wrong dates on the parent folder. For file moves, the situation is a bit better, only the date accessed gets messed up (IMO the least useful of the three). For folder moves, oddly, the folder creation date is the only one that remains intact.
Mode 1: Standard
Mode 2: Set Folder timestamps based on the files inside.
Created completely in C#, and .NET 2.0 using Visual Studio 2010 (WinForms).
Source is available upon request.
Authored by genBTC.
Date: August 24, 2014
How to Use:
Mode 1: Standard Mode
Take note of the "Recurse" checkbox, and "Perform on files" checkbox.
Starts at the root folder, works its way down(deeper).
Mode 2: Recursively Set Folders based on Files/Dirs Inside
Starts at the root folder, inspects whats inside, decides what to use as the time source (either file or subdir), oldest/newest/random file, and which attribute (or any/random) based on what radiobuttons are used. Then sets the date of the root folder on what is in the root folder. Then it recursively digs deeper and repeats the same process for any/all subdirectorys. Does not change dates of any files.
After clicking the "Update" button, in either mode, a second "Confirm" window will open up.
This confirm window is an essential part of the program, where you can double check what exactly will be done, remove from, add to, change date/times, and open Windows Explorer.
The confirm window has a choice of "Update if date is newer/older/always" - a filter mask, that applies once you click the final "Confirm" button.
Behavior/Quirks:
-From Currently Selected cannot be selected if nothing on the right side is selected.
-To unselect something (since Ctrl click doesnt work) on the right side, there is a small blank empty space next to the scrollbar that you can click. (Outside of the first column).
-On the confirm window, there is an issue where selecting items will cause the checkboxes to change. I built in a protection circuit that will prevent this (to make it seem normal) but you will find that if you try to change the checkboxes within 800ms of selecting something, it won't let you. The other side of this means that if you manage to hold the mouse button down for more than 800ms between when you select something and when you let go, you will bypass the protection and the checkbox will change. I have not found a better solution for this, as it is inherent in the ListView control for WinForms.
A Side Note on Read Only Folders:
-Read only folders are actually not what you think they are. Windows uses the folder read-only flag for internal purposes. The checkbox in the Windows Explorer Properties window of a user folder serves only one purpose, it is there to allow a user to change the read-only status of All the sub-files inside the folder at once. It _is_ possible to change the folder read-only flag to "not read-only" (with attrib -r) but absolutely nothing is gained by doing this. This confusing checkbox is not to be confused with PERMISSIONS. For further reading It is not recommended to change the read-only flag on folders such as C:\Windows\Fonts, because it literally is what makes the special custom view be displayed. This program should still modify Timestamps of read-only FOLDERS but not read-only files (unless it is desired/set).
Subscribe to:
Posts (Atom)