|
|
Thank you.
I have already referred this and I mentioned this in my question also. I asked the question because I am not able to understand how to refer multiple tables on FunctionImport and Return Types.
Anyway, I found out already. Thanks for your help.
|
|
|
|
|
I have a stored procedure that returns multiple result set. I tried to use Translate method to handle this, however, I am not able to call this method, as it is giving error such a method doesn't exist. I am using .Net Framework 4.5 and Entity Framework 5.0. Following is what I have tried.
using (var db = new MyEntities())
{
using (IDbConnection oaConnection = db.Database.Connection)
{
using (IDbCommand oaCommand = oaConnection.CreateCommand())
{
oaCommand.CommandType = CommandType.StoredProcedure;
oaCommand.CommandText = "gsp_get_emp_details";
oaCommand.Parameters.Add(empInput.EmployeeId);
oaCommand.Parameters.Add(empInput.UserId);
oaCommand.Parameters.Add(empInput.RoleList);
using (IDataReader dataReader = oaCommand.ExecuteReader())
{
EmployeeData empData = db.Translate<EmployeeData>(dataReader as DbDataReader);
}
}
}
}
I tried using by calling
using System.Data.Objects; , however it is giving compile error on db.Translate. It is giving the message that "project does not contain a definition for Translate...". May I know what's wrong with the above code? Thanks in advance for any help.
|
|
|
|
|
I'm pretty sure that you should be using Translate on an ObjectContext .
|
|
|
|
|
Thanks a lot!!!. I was using DBContext. I was little aware of ObjectContext. I done some examples now. This link is useful, hope it will be useful for someone.
This link also much useful how to get objectcontext references.
Thanks again..
modified 12-Jul-14 16:14pm.
|
|
|
|
|
Can someone tell me how to do that? There is tons of examples in the internet, but they don't cover self hosted WCF libraries. Please if anyone, share some code, bwt i need app.config configuration, and feature to enable CORS and REST
|
|
|
|
|
You might be best asking the specific WCF forum[^]
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
You can't have a self-hosted library. A library is something that is used by something else.
You need some sort of host - a process. Simplest thing to do is a simple console app.
Regards,
Rob Philpott.
|
|
|
|
|
no i can, start new wcf library template from visual studio, and you will have self hosted wcf, which plugs into windows wcf-hoster.
|
|
|
|
|
i create a s/w , by C# (visual studio) , at backend mySql. i create exe file which i create in visual studio.
so my Question is-
a)if i install the exe file in other computer then i have to install Mysql workbrench on that computer ?
b)if yes then how can i install it?
|
|
|
|
|
Don't post this in multiple places - it wastes time and annoys people.
You have it posted in QA, leave it there.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
No, you shouldn't have to. Presumably your exe is using MySQL 'driver' assemblies, so as long as they are distributed with your .exe you should be fine.
Regards,
Rob Philpott.
|
|
|
|
|
Hi
I need to populate a datatable with two fields from an xml file.<partnum> and <actualqtynum>
The file was obtained from a report that opens in a web browser, and the file saved from there.
DataTabel.ReadXml(XMLFilename) fails (complains about the ':' character in Line 2 of the xml file.)
I thought about using something like below, since I do have a complete list of the <partnum> in another table, but the <actualqtynum> is not a child node of <partnum> , and this also fails (complains about the ':' character in Line 2 of the xml file.)
public string GetKeyValue(string key)
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(_XMLFileName);
System.Xml.XmlNode Node = xd.DocumentElement.SelectSingleNode("/REPORTTABLE/REPORTTABLEDETAILS/PARTNUM add[@key=\"" + key + "\"]");
if ((Node != null))
{
return Node.Attributes.GetNamedItem("value").Value;
}
else
{
return null;
}
}
Any idea how I can get a list of PARTNUM with the corresponding ACTUALQTYNUM?
="1.0"="Shift_JIS"
="text/xsl"="../Bin/KITSCHREPFLEXA.xsl"
<DOCUMENT>
<REPORTHEADER>
<REPORTTIME>2014/07/11 13:36:44</REPORTTIME>
<CREATEBY>Fujiuser</CREATEBY>
<SCHEDULENAME>Week_23_2014</SCHEDULENAME>
</REPORTHEADER>
<REPORTTABLE>
<REPORTTABLEDETAILS>
<JOBNAMES><JOBNAME>260-C536000-PACE - Top_TLine 1 / Line 1 / Top / 1</JOBNAME></JOBNAMES>
<JOBNAMES><JOBNAME>260-C536000-PACE - Top_BLine 2 / VEK Line 2 / Bottom / 1</JOBNAME></JOBNAMES>
<DATANUM>38</DATANUM>
<PARTBARCODE>938-1030507</PARTBARCODE><ORIGINALPARTBARCODE>938-1030507</ORIGINALPARTBARCODE><PARTNUM>938-1030507</PARTNUM>
<SUPPLYNUM>2</SUPPLYNUM>
<ACTUALNUM>2</ACTUALNUM>
<REMAINSNUM>0</REMAINSNUM>
<QTYSUPPLYNUM>4</QTYSUPPLYNUM>
<QTYACTUALNUM>6249</QTYACTUALNUM>
<QTYREMAINSNUM>6245</QTYREMAINSNUM>
</REPORTTABLEDETAILS>
<REPORTTABLEDETAILS>
<DATANUM></DATANUM>
<PARTBARCODE>948-1025627</PARTBARCODE><ORIGINALPARTBARCODE>948-1025627</ORIGINALPARTBARCODE><PARTNUM>948-1025627</PARTNUM>
<SUPPLYNUM>2</SUPPLYNUM>
<ACTUALNUM>1</ACTUALNUM>
<REMAINSNUM>-1</REMAINSNUM>
<QTYSUPPLYNUM>40</QTYSUPPLYNUM>
<QTYACTUALNUM>6720</QTYACTUALNUM>
<QTYREMAINSNUM>6680</QTYREMAINSNUM>
</REPORTTABLEDETAILS>
|
|
|
|
|
|
Thanks for your reply Richard.
From W3.org it seems the file is possibly not 100% compliant
xml:stylesheet should be
xml-stylesheet
But even so, I eventually got hold of the stylesheet which did not have any Schema info.
Also tried DataSet.ReadXml as many posts on the net suggested where a schema was not available with no luck.
Ended up reading the file with StreamReader.ReadLine and picking out the values I needed with SubString(...)
|
|
|
|
|
Having to deal with defective XML files is always fun... My 5 for seeing that little difference.
Alternatively to your solution, write the file back line by line, just omitting the "bad" line. With that file, some tools could generate classes for its content, and thus making the access to the properties easier.
The Japanese encoding could cause some more fun later on, be prepared for that.
|
|
|
|
|
C# Code
using System;
using System.Collections;
namespace Loop_Test
{
public class ForLoopTest
{
static void Main()
{
int Ticks = 0;
int Bit = 0;
int Ask = 0;
int Bar1 = 22;
for(int i = 0; i < 22 ( Bit + Ask) ; i++)
Console.WriteLine("Bar1");
}
}
}
This is one of bar from 22 Ticks ,Stock bar chart (Bid,Ask,Open,High,Low, Close).
When bar close must have Variable (Bit&Ask) Total= 22;
Can somebody help me with this loop.
David.
|
|
|
|
|
A few things:
1) Do you want to loop until (Bit + Ask) = 22?
2) The value of Bit,Ask and Bar1 are not changing from 0
3) If you want to display the value of Bar1 then you should put Console.WriteLine(Bar1.ToString());
(Console.WriteLine("Bar1") will display 'Bar1' and not the value of the variable Bar1)
for (int i = 0; (Bit + Ask) < 22; i++)
{
Console.WriteLine(Bar1.ToString());
}
|
|
|
|
|
|
Why Sql server don't convert dateformat (dd-mm-yyyy) or (yyyy-dd-mm) ?
I have face this problem many times. why sql server don't accept any format like C# datetime ?
|
|
|
|
|
I guess I am a little confused, I use MySQL and do not have to change the DateTime. are you just looking to place the Date in there?
|
|
|
|
|
SQL uses DateTime types which do not have a format; you should convert date strings to DateTime s before storing in the database.
|
|
|
|
|
Converting strings to dates in SQL Server depends on the current DATEFORMAT option[^]. This option will be one of mdy , dmy , ymd , ydm , myd , or dym ; the default is mdy .
You should try to avoid converting strings to dates (or vice-versa) in SQL; that sort of code belongs in the user-interface code. However, if you absolutely have to specify a date as a string, you should use an unambiguous format - namely yyyyMMdd . Don't add any separators, as dates with separators are still liable to change based on the culture and settings.
MSDN has a list of the supported string literal formats for dates:
http://msdn.microsoft.com/en-gb/library/ms187819.aspx#sectionToggle1[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The major problem is that SQL doesn't have a clue where the date is coming from: it is nearly always running on a different computer from the code that sent the date to the DB, and probably the user entered it on a third computer!
So what is is supposed to do with:
12/11/10 SQL doesn't have any access to cultural information about how the user is likely to have intended that, so it doesn't know if the year is 1912, 2012, 1911, 2011, 1910, or 2010 - or some other date system altogether, given that in the Iranian calendar (also known as Persian calendar or the Jalaali Calendar) this year is 1389, but it's year starts around 21st March in the Gregorian calender which complicates thinges even further.
Since is can't get it right - or even make an educated guess - it doesn't try. It expects you to do teh work for it, and either present it with a date in DateTime format already from your external code, or in ISO format: yyyy-MM-dd HH:mm:ss
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
When you insert / update data on the SQL Server, do not use a "simple" query which contains all values as strings. Use a parameterized query, and then add the parameter's value (as a C# DateTime value of course, not as a string!); the parameterized query will handle all those formatting quirks for you automagically!
|
|
|
|