473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Tricky VB to C# conversion

I am trying to convert some VB that uses Linq into C#
Is there anyone out there who is kind enough (clever enough) to show
me how to convert the following Sub loadAddress into C# for me.

Sub DoIt()
Dim WWV5 As New WWV5DataContext
Dim Xorg As Object

If Roles.IsUserInRole("Admin") Then
Xorg = (From o In WWV5.ORGs Where o.OrgID = ID Select o).Single
Else
Xorg = (From o In WWV5.ORGScopies Where o.OrgID = ID Select o).Single
End If
loadAddress(Xorg)
End Sub

Protected Sub loadAddress(ByRef pOrg As Object)
txtName.Text = pOrg.OrgName
txtCharNum.Text = pOrg.CharNum
txtAdd1.Text = pOrg.Add1
End Sub
Mar 1 '08 #1
2 1092
Oh; one other thing; data contexts are usually disposable, so I'd
actually have something like:

using(var ctx = new WWV5DataContext()) {
Org org;
if(Roles.IsUserInRole("Admin")) {
org = ctx.ORGs.Where(o=>o.OrgID == ID).Single();
} else {
org = ctx.ORGScopies.Where(o=>o.OrgID == ID).Single();
}
LoadAddress(org);
}
Mar 1 '08 #2
Hello Marc,

Me again !
I forgot to mention that the using statement you suggestion did not
work. error:Cannot implicitly convert type 'ORGScopy' to 'ORG'

I hope you have not gone home :-)

Regards,

Pete
Mar 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
4
by: Jyrki Keisala | last post by:
I have an XML file: <document> <record> <element1>Text</element1> <element2>More text</element2> <element3>Even more text</element3> <element4>Some text <link><title>Google</title><url>...
19
by: Kai-Uwe Bux | last post by:
Hi folks, I have trouble writing a class, derving from stringstream, that collects item and once it's done will write them to std::cout in one go. It works fine except when I use it as a...
8
by: daniel.w.gelder | last post by:
Hello, I have a template with two typenames. template <typename BASE, typename SUPER> struct Morphic { Morphic<BASE,SUPER>( ) { .. } ~Morphic<BASE,SUPER>( ) { .. } }; Morphic takes a Base...
25
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
6
by: Thomas Tomiczek | last post by:
Ok, working my way through a complex library conversion to .NET 2.0 and C# 2.0 with generics I am totally stuck on one thing -if anyone sees the issue I would be more than glad. The situation is...
3
by: Old Wolf | last post by:
Here is a simplified version of a post I saw on another NG: struct Base {}; struct Derived: Base {}; struct ConstPtr { //operator const Derived * (); // F1 operator const Derived *...
15
by: fungus | last post by:
I'm moving some code from VC++ 6 to VC++ 2005 and I've run into a nasty problem because iterators are no longer pointers. In the program I'm moving, there's a std::vector of items hidden inside...
11
by: onkar | last post by:
Program 1: #include<stdio.h> int main(void){ int *p; p=(int *)malloc(sizeof(int)); *p=12; printf("%d %p\n",*p,p); return 0; }
2
by: jbaranski | last post by:
I've working on conversion data related to our benefits. Our benefits eligibility date is as such, the first of the month 30 days after your hire date. ex. Hire Date = 11/5/2008. the 30 grace...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.