Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch n bind data from StoredProcedure with Join, LINQ then Split. using IMultipleResults,Linq2SQL

I have an application in which I am using a stored procedure and LINQ. My procedure looks like this:

myProc

select col1, Col2, Col3 from Tab1 inner join Tab2 on col1=ColA  join tab3 on Col1=ColD

Select cola, Colb, Colc from Taba inner join Tabb on cola=ColX  join tabc on Cola=ColY

Select colP, ColQ, ColR from TabP inner join TabQ on colP=ColW  join tabR on ColP=ColZ

I am executing this stored procedure in LINQ. When I execute it I am getting the results in IMultipleResults.

Below is my code in LINQ:

[Function(Name = "dbo.MyProc")]
[ResultType(typeof(TabA))]
[ResultType(typeof(TabB))] .....
public IMultipleResults GetMultipleResults([Parameter(DbType = "VarChar(50)")] string i_Cola)
{
    IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), i_Cola);
    return (IMultipleResults)result.ReturnValue;
}

When I execute it as follows:

MyContext mCtx = new MyContext()
var allResult = mCtx.GetMultipleResults(txtName.Text.Trim());
IEnumerable<Taba> TabaRes = allResult.GetResult<Taba>();
IEnumerable<TabB> TabbRes = allResult.GetResult<Tabb>();

I am getting the column values of tables but I want the Inner Joined columns also. I've referred to many blogs and forums, such as...

  1. Ben Hall's Blog
  2. Guy Burstein's Blog
  3. Microsoft's Blog

... to try to find a solution to my problem, but couldn't find any.

like image 229
Umakanta.Swain Avatar asked Oct 15 '10 09:10

Umakanta.Swain


1 Answers

well better to use views in respect to SP(If u are not able to write a linq to sql query),if u are using Linq to Sql its worthLess to use Sp becoze it decrease the performance.and one more thing if u are using Linq to sql there is no Need to use any type of join if ur data base is completely normalized. If still ur prob is not solved just show me the table structure and what the out u need i will write a query for u...

like image 72
slash shogdhe Avatar answered Oct 14 '22 11:10

slash shogdhe