|
Hi Mark, thank you very much for your reply. I realized that I need to know a pattern using DataContext. I have following code in my ASP.NET page. I am wondering If it is more efficient to place the line SpDBDataContext myDbContext = new SpDBDataContext();
globally and override the Page's Dispose method and call the myDbContext.Dispose() method inside that Disposer !!
protected void _linqDataSourceProductsFirst_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
using (SpDBDataContext myDbContext = new SpDBDataContext())
{
var productResults = myDbContext.products.Where(x => emran.publish).OrderBy(x => x.isFeatured);
e.Result = productResults;
}
}
About using layered system, actually I know layered system as I used to have Data Access Layer whole life until I learned LINQ to SQL. I always hated data access layer because, if I change a table schema in my SQL server database, I had to manually find out my data acccess layer which code needs change as the application will still compile with a wrong SQL Schema. So, when I learned LINQ to SQL, I just felt great and new I feel free to change any table column in SQL server and then, drag and drop the new Table to the ORM page and then, I get error in compile time where the usage needs changing. So, to my point of view, the ORM page (.dbml page) is working as a data access layer where I place my LINQ query directly within my code. It is just for maintainance peace.
modified on Thursday, April 1, 2010 1:26 PM
|
|
|
|
|
Emran Hussain wrote: I used to have Data Access Layer whole life until I learned LINQ to SQL.
LinqToSql doesn't change anything.
Emran Hussain wrote: I always hated data access layer
Then, very bluntly, you are a fool.
Emran Hussain wrote: the ORM page (.dbml page) is working as a data access layer
Then you don't really understand layered design or how to use the tools effectively.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi Mark,
I agree with you that I need more knowledge about it. Actually so far I did not find any article that discuss any Design Pattern using LINQ to SQL. If I search for LINQ to SQL article, I find millions of links which teach about the LINQ query expressions. Anyway, thank you for your help.
|
|
|
|
|
Emran Hussain wrote: I did not find any article that discuss any Design Pattern using LINQ to SQL
Because patterns are not depended on any particular technology.
"In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations."
http://en.wikipedia.org/wiki/Design_pattern_(computer_science)[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi, Can you please tell me how I can select all controls with ctrl+a at runtime?
|
|
|
|
|
at runtime? How it could be? you can define your own routines that draws a selection rectangle around every control when the user hits Ctrl+A.
Regards,
Mohammad Elsheimy
---------------------------
Just Like a Magic
http://JustLikeAMagic.Wordpress.com
|
|
|
|
|
By the way what you want to do after selecting all control at runtime
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
I will modify the selected ones' values all at a time
|
|
|
|
|
can you at least tell me how I can detect ctrl+a key combination? Below one seems to be not working
if ((Control.ModifierKeys & Keys.Control) == Keys.Control & (Control.ModifierKeys & Keys.A) == Keys.A)
{
MessageBox.Show("test");
}
|
|
|
|
|
It is simple you can use this under KeyUp/KeyDown event
if (e.KeyCode == Keys.A && e.Control)
{
Messagebox.show("");
}
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
Hello,
I have strange problem. In one of my project I used the "ParameterCollection" class to pass a number of SQL Command parameter to a method. In the first system I used like
ParameterCollection coll1 = new ParameterCollection();<br />
coll1.Add(new Parameter("categoryName", DbType.String, categoryName));
It works fine, but when I try the same code in a second computer it generates an error
"The best overloaded method match for 'System.Web.UI.WebControls.Parameter.Parameter(string,System.TypeCode,
string)' has some invalid arguments"
This confused me for a while, finally I figure out the problem when I tried the following at the new computer
ParameterCollection coll1 = new ParameterCollection();<br />
coll1.Add(new Parameter("categoryName", TypeCode.String, categoryName));
it works fine
But finally I got amazed when I saw the number of overloaded constructors in two systems are different.
In the first system it has 6 overload constructors for "Parameter" class(two of which support DbType as parameter ) and in second system it has only 4 overload methods(no DbType support).
In both system we used Visual Studio Express 2005 with .net 2.0 framework, but the only difference is the first system installed with Visual Studio 2008. will it affect ?
modified on Thursday, April 1, 2010 7:04 AM
|
|
|
|
|
I checked your scenarios on 2 machines and i got following results
PC having only VS2005
Parameter constructor had 4 overloads
out of which none supported TypeCode as parameter
PC having VS2005 & VS2008
Parameter constructor had 6 overloads
out of which 2 supported TypeCode as parameter
So I think the second PC has VS2008 installed in it so it contains an updated .Net Framework API
Tej Aj,
http://opexsolution.com/forum/
|
|
|
|
|
So this may be an issue, when you develop on a machine that has VS2008 and target version is framework 2.0, then host your application on a machine which only has framework 2.0. I am still wondering, installing VS2008 which means framework 3.5 on a machine update already installed framework 2.0 ? Or is this an issue of Service Pack ? So the portability of dotnet framework on question
Thanks for your effort
modified on Friday, April 2, 2010 12:29 AM
|
|
|
|
|
That would be a .net version issue, not Visual Studio.
You should have the latest version of .net installed regardless of whether or not Visual Studio is installed.
You could also develop for .net 2.0 even when using VS 2008.
|
|
|
|
|
But still i used the same framework 2.0 on two different machines, so I should get same number of constructors in two different machines, so how we rely on .net's so celebrated code portability and all?
|
|
|
|
|
Hi Guys,
I normally try to answer these sort of problems myself but i seem to be really digging myself into a hole here for a relativly simple question. Would really appreciate advice.
I have my main form: Creator.cs
On this form is an btnOption whick opens another form, Option.cs, and also a run program (GO!) button.
Option.cs contains two check boxes which are, by defualt Checked = true. I am happy with this and most of the time this will be the case.
However I want my program to check OptionBox.checkboxIncludeFiles and OptionBox.checkboxIncludeFolders too see if the user has unchecked them. I am unsure of how to look at the current values of these to implement it within the main() on Creator.cs. Just to clarify I'll put my ideal set up below, it's obviously wrong but just my guess.
Also, I am assuming here but changing the checkbox value and then closing the Option.cs form, the values for the checkbox reamin changed. As you may guess I am a little confused.
Many Thanks for any help!
Steve
Creator.cs
btn_G0_Click
{
if OptionBox.checkboxIncludeFolders.Checked == true
Run code with loop
else
Run code once.
}
|
|
|
|
|
If I get you properly,
you can set checkbox Modifiers property to public, will allow you to access of checkbox control and its property.
Never unload your options form. just hide from user.
Thanks
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
Making controls of a form public is really a bad practice. We have properties and delegates to share data between the forms. One should make use of that.
|
|
|
|
|
You can make use of delegate and handle the check changed event for both the checkboxes in Creator.cs. In the event handler, assign the checked state values to a boolean variable. Then, you can use that in the Go button click event handler and proceed.
|
|
|
|
|
Ok so delegates seem to be the best option. These are completly new to me. How do I assign the boolean variable to a delegate and how to I pass it to Creator.cs?
Anything is useful, I'm having a look at delegate tutorials now.
Many Thanks again
|
|
|
|
|
Steve-Co wrote: How do I assign the boolean variable to a delegate and how to I pass it to Creator.cs?
You do not need to do this. You need to handle the check changed event of the checkboxes in Creator.cs. In the event handler, assign the check state to a boolean variable declared in the Creator.cs. Something like this:
class Creator{
public bool includeSubFolder = true;
private void CheckChangedEventHandlerMethod(object sender, CheckChangedEventArgs e){
CheckBox chk = sender as CheckBox;
if(chk != null){
includeSubFolder = chk.Checked;
}
}
} *
Steve-Co wrote: Anything is useful, I'm having a look at delegate tutorials now.
This[^] is what I found right now. It is for a web control, but the concept remains the same.
Hope it helps.
*Code might not work since I typed it right here and not in VS. Please bear.
|
|
|
|
|
You can
0) Pass the checkbox.Checked property values to the child form, or
1) Specify the child.Parent property to this from the parent form, or
2) Create a static class that holds the values of the parent checkbox.Checked properties and refer to that static object from both forms.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
...
3) Define a class to hold the configuration, create and pass an instance of it to the child, which can then set it as required.
|
|
|
|
|
Thank you all for your replies.
As I stated this was a simply problem and I choose to solve the easy way. Put the check boxes in Creator.cs rather than in a different cs.
One day i'll hopefully understand and implement properly. I understand this shouldn't be difficult. I just need to clear my understanding of OO.
Thank you all for your help
|
|
|
|
|
Dear all,
Currently, I'm finding the best sort algorithm for my case as below:
I already have 3 input arrays that are increment sorted by times (each array contains about 1,000,000 elements).
Now, I want to merge 3 arrays to one arrays (of course, it must be sorted).
Pls. support me to find the best way to do it, to improve performance as much as posible.
Thanks for your support!
|
|
|
|