w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How-to edit EDMX programmatically
Well, what I wanted was a free library which contained the object-model representation of the EDMX. This would allow developers to edmx.Load(pathToEdmx), query the object-model, make changes, and edmx.Save(). Apparently, such a library doesn't exist. So, I wrote some code to load the XML, query the XML, make some changes, and save. Not as rich as an object-model with validation and helpful exceptions (and very prone to typos), but it worked.

Categories : Entity Framework

Generating EDMX output with PLINQO EF and Oracle takes extremely long or is stuck
I couldn't find a solution to this. In the end, I installed ODAC into visual studio and generated an EF edmx using visual studio. Note that this is only possible with VS professional or better. VS Express does not support installing thirdparty tools like SQL*Plus.

Categories : C#

asp.net generating radiobuttonlist programmatically
Use CheckBoxList instead - by design it's used when multiple choices are desired. EDIT Gotcha - use this instead. Your loop just kept referencing the SAME RadioButtonList since it was already defined on the page. I just removed your RadioButtonList, added it back programmatically, added a PANEL to add it/them to the page, and removed the no longer needed end braces. <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="sandbox._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="

Categories : Asp Net

Programmatically generating OWL class hierarchy with Jena
Your question isn't very clear (see comment, above) so I'm going to take a guess that you want to programmatically create a class hierarchy. The outline code for doing this using Jena would be: OntModel m = ... your model ... ; NS = "http://your.domain/example#"; // define the various classes OntClass layer = m.createClass( NS + "Layer" ); layer.setLabel( "layer", "en" ); OntClass networkLayer = m.createClass( NS + "NetworkLayer" ); layer.setLabel( "network layer", "en" ); // ... // create the class hierarchy layer.addSubClass( networkLayer ); // ... // save the file FileWriter out = null; try { out = new FileWriter( "./test.owl" ); m.write( out, "RDF/XML-ABBREV" ); } finally { if (out != null) { try {out.close()) ) catch (IOException ignore) {} } }

Categories : Java

Generating ListView Adapter programmatically during runtime
Okay, I found a solution. You have to define a new ArrayAdapter inside the setListAdapter()-methode and override the getView()-methode. setListAdapter(new ArrayAdapter<string>(this, R.layout.list_item, strings) { @Override public View getView(int position, View convertView, ViewGroup parent) { View row; if (null == convertView) { row = mInflater.inflate(R.layout.list_item, null); } else { row = convertView; } TextView tv = (TextView) row.findViewById(android.R.id.text1); tv.setText(getItem(position)); return row; } });

Categories : Java

Generating Table in Telerik Report Viewer Programmatically
Apparently, this is a newer issue with the later Telerik reporting. I found the answer in the Telerik forums here: http://www.telerik.com/community/forums/reporting/telerik-reporting/incorrect-dynamic-table-columns.aspx Basically, you need to assign a unique name the TableGroup column: TableGroup tableGroupColumn = new TableGroup(); //add this : tableGroupColumn.Name = i.ToString();

Categories : C#

Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together)
My solution for these kinds of issues was to use a legitimate programming language to compile a template into a CloudFormation JSON document. I used PHP 5.4, Twig and Symfony Console, but YMMV. Essentially, you do the math ahead of time in the programming language, then use that data as you write-out your JSON document.

Categories : Amazon

EDMX .NET 4.5 to 4.0?
Assuming you don't use features that shipped with .NET Framework 4.5 (enums, spatial types, stored procs with multiple result sets) you can do the following (be sure to back the file up just in case): Create a new console app targeting .NET Framework 4.5 Add the edmx file to the project Retarget the project to target .NET Framework 4 (go to project properties, change target framework version) This should result in downgrading your edmx to v2. Alternatively you could manually change xml namespaces and versions to v2. You can find what namespace to use for each version of the artifact here: edmx csdl ssdl msl Edit Note that with EF6/EF6.x you can use Edmx v3 on .NET Framework 4 and therefore get all the goodnes (like enums) that was before only available on .NET Framework 4.5

Categories : C#

Why use EF 5.X DbContext Generator when Edmx does the same job?
When you add the new "ADO .NET Entity Data Model", apart from creating the EDMX it also creates the DbContext for you, it's "AdventureWorks_DataEntities". So, you don't need to add a "EF 5.X DBcontext Generator", this already exists in your project. If in Visual Studio you click on the arrow on the left of your .edmx file to unfold it, you'll see several files. Two of them will end in ".tt". These are T4 templates, which are in charge of generating the model entities and the DbContext automatically when you modify the EDMX. Hope this clarifies the concepts, to answer your questions directly: Question 1: You only need step 1, "AdventureWorks_DataEntities" is your DbContext. If you open the "AdventureWorks_DataEntities.cs" file you'll see this class inherits from DbContext. Question 2: T

Categories : C#

Parse xml ( edmx ) attribute with namespace
The XML starts with <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"><edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> so one way to access the attribute of each DataServices element is XmlNamespaceManager nsMgr = new XmlNamespaceManager(navigator.NameTable); nsMgr.Add("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx"); foreach (XPathNavigator dataServices in navigator.Select("edmx:DataServices", nsMgr)) { string version = dataServices.GetAttribute("MaxDataServiceVersion", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"); } If you want the attribute value of the first such attribute then doing nsMgr.Add("m", "htt

Categories : C#

Check edmx validity from database
EDMX is a text-based format, it uses XML on the inside. So you can use a diff. Generate an EDMX from your current database version Open the EDMX your customer sent you Diff both files using a utility of your choice You will see the differences pretty quickly. The XML is also easy to read, so you can know where exactly the problem lies. If you want to automatically check it at runtime, you can still use this method, as long as the customer's app contains an EDMX file fitting their database version (just package it when you are delivering the appliaction). Then use a library to do the diff. Update I am not sure that you can generate an EDMX file at runtime, but if there is a solution, it probably involves the EdmxWriter class. If this does not work, and you absolutely have to do

Categories : Entity Framework

Stored Procedures and updating EDMX
The only fix I could find was to close the EDMX, and manually edit the XML, which, even after removing the stored proc from the database, and updating the model from the database - still had mention of the proc. Removing the lines from the XML has solved the issue.

Categories : C#

Asp.net mvc 4 Large database using edmx is good?
IMHO, you may use Entity Framework 5 without EDMX. Use any approach with EF5 - Code-First or Database-First and you should be good to go. You will have a create a context to the database. It will save you from creating any EDMX file and other associated files. Here is an MSDN link to get started. Visit MSDN link to choose the right approach. Another link for EF v4.1. Please take this as a starting point.

Categories : Asp Net

Edmx not returning auto incremented value
Could you check the following articles: problem description: http://connect.microsoft.com/VisualStudio/feedback/details/505178/storegeneratedpattern-property-in-ado-net-entity-model-designer-sets-cdsl-annotation-but-not-ssdl-attribute solution to the problem: http://visualstudiogallery.msdn.microsoft.com/a63745c0-a781-48fa-a7d2-573ee80b5d7e

Categories : C#

EDMX is overwriting Key data annotations
You could update your T4 template to add in the data annotation for you on primary keys? if (simpleProperties.Any()) { foreach (var edmProperty in simpleProperties) { if (ef.IsKey(edmProperty)){ #> [Key] <# } #>

Categories : Entity Framework

Adding Hand-Built Models to an EDMX
Typically when you use the designer the flow is the opposite - you create the model with the designer (or create/update the model from the database) and then the code is created for you. The created code can be either the EF1 style code with entities derived from EntityObject and attributes etc. which is created with a Single File Generator which is a part of VS (Code Generation Strategy set to "Default") or the code can be created with T4 templates (Code Generation Strategy set to "None") in which case you need to add T4 templates to your project. EF matches POCOs with Entities from the edmx file by convention (names of entities have to be the same, names and types of properties have to match etc.). In the article for some reason they went the opposite way which is weird since it requires

Categories : Entity Framework

Many to Many Relationship, EDMX shows no primary key warning?
The behaviour for your question #1 is by design - assuming that your junction table, StudentsSubjects has only the 2 columns, being the foreign keys StudentId and SubjectId, then EF will hide the junction table and instead provide one-to-many navigation from both Student and Subject. (Microsoft calls this a Pure Join Table). For this EF N:N behaviour to work, no other columns are permitted in the junction table, not even a simple surrogate key (as suggested by @SQL.Net Warrior). To avoid the warning in question #2, the primary key for the junction table would thus need to be the composite key (StudentId, SubjectId), i.e. ALTER TABLE StudentsSubjects ADD CONSTRAINT PK_StudentsSubjects PRIMARY KEY (StudentId, SubjectId); See also How to set up a many-to-many relationship in Entity Fra

Categories : C#

How to do a join on two tables with Linq using this EDMX diagram?
Try this: from student in ctx.Student select new { Student = student, Subjects = from studsub in student.StudentsSubjects select studsub.Subject }; The relationships look fine.

Categories : C#

how to manage two EDMX files incase they have the same table name
You may change the name of the table on designer. Click the entity on designer and click and change the name property. Or you may have these two edmx in different name spaces (If it is possible)

Categories : Asp Net Mvc

Updating EDMX from SQlite-file fails in VS2012
Does the show in Datasources in VS? View the Model.edmx as XML (right click -> open with) See if that give you more info. Stack Model Generation info

Categories : C#

Updating table Fields Using EF Database First usind EDMX
Really strange. Try it this way: customer.Modified = DateTime.Now; // This should find Customer by EntityKey and apply all fields to context entry // so you shouldn't assign each property value _context.Customers.ApplyCurrentValues(customer); _context.SaveChanges(); Or may be it is better to implement Modified field behavior at the database level as a SQL UPDATE trigger?

Categories : Dotnet

Requisites to read an edmx file in Visual Studio 2012
The EDMX file is not just XML representing the database structure / mapping but also how the Visual Studio designer should render the diagram (where to place tables, associations etc). I found this project that creates EDMX files programatically (I have NO affiliation with this and found it through good ol' Google).

Categories : C#

Scaffolder unable to load EDMX metadata after upgrading to .NET4.5 and EF5
On day two of this adventure I began converting EF.Utility.CS.ttinclude into a C# console app to see if I couldn't glean a better error message. I noticed that the constants at the bottom of the file didn't include the newer EF5 namespaces. I compared my copy with the one under "C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDEExtensionsMicrosoftEntity Framework ToolsTemplatesIncludes" and sure enough, mine was out of date. During my debugging, I know I updated this (as I mentioned above). Either I copied it to the wrong folder, or I'm losing my mind. It could be either at this point. Either way, the solution was simply to update my local copy of EF.Utility.CS.ttinclude with the one under "C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDEExtensionsMicrosoftEntity Fr

Categories : Entity Framework

Add UISearchBar programmatically to a programmatically added UITableView in a normal ViewController
Is your object implementing the delegate methods in UISearchDisplayDelegate? In other words, you have to define what happens when text is entered in the search bar, it does not happen automatically for you.

Categories : Objective C

Upgrading EF in pregenerated views: The default target Entity Framework version requires the edmx schema version 2 or lower
I found the solution to my problem... There was a leading help in the following link: http://blog.3d-logic.com/2012/05/28/entity-framework-code-first-and-pre-generated-views/ moozzyk says: August 5, 2012 at 11:51 pm I did see this when using Visual Studio 2012 and EF5. For now the workaround is to edit the >template. Change the line 70 from: var errors = viewGenerator.GenerateViews(mappingItemCollection, writer).ToList(); to: var errors = viewGenerator.GenerateViews(mappingItemCollection, writer, >EntityFrameworkVersions.Version3).ToList(); Sorry for the inconvenience. I had to slighlty modify my code in a similar way, from: IList errors = viewGenerator.GenerateViews(mappingItems, writer); To: IList errors = viewGenerator.GenerateViews(mappingItems, writer

Categories : Entity Framework

How do I get to use Model1.foo instead of Model1.edmx, and invoke IModelConversionExtension callbacks
OnAfterFileLoaded is supposed to be invoked if you load a file whose extension is different than edmx and the IEntityDesignerConversionData.FileExtension returns a value that matches your extension. OnBeforeFileSaved works the opposite way - on save. However - I looked at code in this area today and concluded that it actually cannot work. I filed a work item for this: https://entityframework.codeplex.com/workitem/1371

Categories : Entity Framework

EDMX object reference not set to instance of an object
I assume that lgn is null, as usr maye have returned the default value null and assigned it to lgn. Therefore you can check that lgn is not null: if (lgn != null && !string.IsNullOrWhiteSpace(lgn.Email) { user = lgn.Email; } user = "User not found/Email has not been set";

Categories : C#

Generating pdf in asp.net
Use itextsharp for generating pdf http://sourceforge.net/projects/itextsharp/ for demo see following link http://www.codeproject.com/Questions/203481/HTML-convert-to-PDF-using-itextsharp

Categories : Asp Net

CTE not generating what I'm expecting?
Your WHERE criteria is excluding that line because MONTH never = 1 for CC = '0017' Instead of starting with MONTH = 1, you could use a ROW_NUMBER OVER (PARTITION BY CC,YEAR ORDER BY MONTH) to identify the first month.

Categories : SQL

R class not generating ids
When you create an activity it will create its default layout xml. As far as i understand your problem, you want the same activity to display a list. If that is the case, i suggest you try to put your design in that default activity layout, that will create id in R. Also i would suggest to go and refer basic android tutorial provided on android developers site under heading "build your first app" that will help.you understand this.

Categories : Android

Generating the Next Id when Id is non-AutoNumber
I hope this works for you. Considering that your ID field is an integer INSERT INTO Table WITH (TABLOCK) (SELECT CASE WHEN MAX(ID) IS NULL THEN 1 ELSE MAX(ID)+1 END FROM Table), VALUE_1, VALUE_2....

Categories : SQL

JSP generating .xml file
while I'm disagree with generating xml with jsp but you can add this section inside web-app(tag) in your web.xml <servlet> <servlet-name>JspXML</servlet-name> <jsp-file>/pages/foo.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>JspXML</servlet-name> <url-pattern>/foo.xml</url-pattern> </servlet-mapping> while you are still can access the xml file by foo.jsp, for preventing that, just put the jsp file in WEB-INF folder

Categories : Java

Generating a hierarchy
The simplest example would be to use a (real or temporary) table, and add one level at a time (fiddle): INSERT INTO hierarchy SELECT id, name, 0 FROM employees WHERE reportsTo IS NULL; WHILE ((SELECT COUNT(1) FROM employees) <> (SELECT COUNT(1) FROM hierarchy)) BEGIN INSERT INTO hierarchy SELECT e.id, e.name, h.hierarchylevel + 1 FROM employees e INNER JOIN hierarchy h ON e.reportsTo = h.id AND NOT EXISTS(SELECT 1 FROM hierarchy hh WHERE hh.id = e.id) END Other solutions will be slightly different for each RDBMS. As one example, in SQL Server, you can use a recursive CTE to expand it (fiddle): ;WITH expanded AS ( SELECT id, name, 0 AS level FROM employees WHERE reportsTo IS NULL UNION ALL SELECT e.id, e.name, level + 1 AS level FROM ex

Categories : SQL

Generating MD5 Hash
The byte-array you get is an md5-hash but with hexadecimal values. You can't just cast your array to a string. You have to convert it with an algorithm that takes those hexa-values and gives you the proper string. Below you can see an algorithm to get the 32bit MD5Hash-String, maybe this helps: public String createHashString(String s) { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] bytesOfMessage = s.getBytes("UTF-8"); byte[] thedigest = md.digest(bytesOfMessage); String hexString = ""; for(byte bi : thedigest) { String hex = Integer.toHexString(0xFF & bi); if (hex.length() == 1) { hexString += "0"; } hexString += (hex); } retu

Categories : Java

Generating a histogram
Use the value to calculate its bin instead of searching for the bin should be both easier and faster. for(int i = 0; i < NumImages; i++) { for(int j = 0; j < edge[i][0]->total; j++) { CvPoint* pt1 = CV_GET_SEQ_ELEM(CvPoint, edge[i][0], j); CvPoint* pt2 = CV_GET_SEQ_ELEM(CvPoint, edge[i][1], j); int bin value = (pt1->y-pt2->y)*scaling; if(value < 0) value = 0.0; int bin = floor(value/binSize); if ( bin < maxBin ) { hist[bin] = hist[bin] + 1; } else { /* Report a lost point if interested */ } } } You will loose points if maxBin * binSize < max(value).

Categories : C++

Generating xml attribute value with XSL
Attribute Value Templates are your friend here. The correct syntax for what you are trying to achieve is <node name="{odnodes/node/name}" host="{odnodes/node/host}" port="{odnodes/node/port}" /> The curly braces here indicate it is an expression to be evaluated, as opposed output literally. Note, you could also use xsl:attribute to create attribute: <node> <xsl:attribute name="name"><xsl:value-of select="odnodes/node/name" /></xsl:attribute> <xsl:attribute name="host"><xsl:value-of select="odnodes/node/name" /></xsl:attribute> <xsl:attribute name="port"><xsl:value-of select="odnodes/node/name" /></xsl:attribute> </node> But as you can see this is more verbose, and you would only really nee

Categories : Xml

Generating temporary PDF via .exe or .NET from PHP
Answering to your questions.... =>. So my first question is, how can I execute a .NET application that requires DLL's from PHP? Sure, you must create a COM Object to interact with it. In the same page you write there's an example for it like this one for openning a com object for a word interaction.... <?php // starting word $word = new COM("word.application") or die("Unable to instantiate Word"); echo "Loaded Word, version {$word->Version} "; //bring it to front $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff $word->Selection->TypeText("This is a test..."); $word->Documents[1]->SaveAs("Useless test.doc"); //closing word $word->Quit(); //free the object $word = null; ?> => Calls a script (either a .NET a

Categories : PHP

Generating random 1's and 0's
Use the Knuth Shuffle on an array initialized with the given percentage of 1s. The following implements it for 25%: #include <iostream> #include <vector> #include <algorithm> #include <random> #include <iterator> void shuffle(double percentage,std::vector<int> &l) { if (l.empty()) return; std::mt19937 gen; unsigned int N_Ones = static_cast<unsigned int>(floor(percentage*l.size())); l[0] = (N_Ones > 0)?1:0; for(unsigned int i = 1; i < l.size() - 1; ++i) { std::uniform_int_distribution<unsigned int> ui(0,i); unsigned int j = ui(gen); l[i] = l[j]; l[j] = (N_Ones > 0)?1:0; } } int main(int argc, char* argv[]) { unsigned int N = 10; if (argc >= 1) N = atoi(argv[1]

Categories : Visual C++

Generating JavaScript with PHP
getElementsByTagName returns a NodeList (an array like object) so you have to do window.onload = document.getElementsByTagName('img')[0].src= msr; to do the first image.

Categories : PHP

Generating a datatable from a dictionary
You do not need to use dictionaries. Parse the CSV directly into the datatable. Private Function csvToDatatable(files As List(Of String), Optional skipxLines As Integer = 0) As DataTable Dim vbReader As Microsoft.VisualBasic.FileIO.TextFieldParser Dim dt As New DataTable 'loop through the files from the list For Each filePath In files If File.Exists(filePath) Then 'keep track of lineCount for each file Dim lineCount As Integer = 1 'setup TextFieldParser for CSV vbReader = New Microsoft.VisualBasic.FileIO.TextFieldParser(filePath) vbReader.TextFieldType = FileIO.FieldType.Delimited vbReader.SetDelimiters(",") While Not vbReader.EndOfData Try

Categories : Dotnet



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.